Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^7: shift in list context buggy?

by BrowserUk (Pope)
on Nov 12, 2013 at 15:36 UTC ( #1062222=note: print w/ replies, xml ) Need Help??


in reply to Re^6: shift in list context buggy?
in thread shift in list context buggy?

Please quote ...

Why? You already posted the examples. But since you seem to have a short memory:

The following equivalences hold (assuming $[ == 0 and $#a >= $i ) push(@a,$x,$y) splice(@a,@a,0,$x,$y) pop(@a) splice(@a,-1) shift(@a) splice(@a,0,1) unshift(@a,$x,$y) splice(@a,0,0,$x,$y) $a[$i] = $y splice(@a,$i,1,$y)

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
div class=


Comment on Re^7: shift in list context buggy?
Download Code
Re^8: shift in list context buggy?
by LanX (Canon) on Nov 12, 2013 at 16:08 UTC
    LOL, are you serious? :)

    splice explicitly talks about list and scalar context and shows later an equivalence table w/o mentioning void-context.

    The intention is obviously to cover all contexts.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      w/o mentioning void-context.

      Are you blind as well as stupid?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Woof, woof!

      The intention is obviously to cover all contexts.

      Nothing at all obvious about that conclusion.

      It is clear to me that the intent was to document the side effects being equivalent with no implications about return values in any context. And you don't have to go past the very first one in order to verify that:

      The following equivalences hold (assuming $[ == 0 and $#a >= $i ) push(@a,$x,$y) splice(@a,@a,0,$x,$y) pop(@a) splice(@a,-1) shift(@a) splice(@a,0,1) unshift(@a,$x,$y) splice(@a,0,0,$x,$y) $a[$i] = $y splice(@a,$i,1,$y) push(@a,'x','y') # returns (2) splice(@a,@a,0,'x','y') # returns ()

      They return different value(s) in both list and scalar context.

      - tye        

        Thanks for showing, I wasn't aware of that.

        IMO one more reason to improve the documentation.

        Cheers Rolf

        ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1062222]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-09-02 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls