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

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)

Replies are listed 'Best First'.
Re^9: shift in list context buggy? (obvious)
by tye (Sage) on Nov 12, 2013 at 16:29 UTC
    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)

        I just love watching you dig yourself into deep holes.

        Funny how that works, huh.


        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.
        A reply falls below the community's threshold of quality. You may see it by logging in.
Re^9: shift in list context buggy?
by BrowserUk (Patriarch) on Nov 12, 2013 at 16:15 UTC
    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.
    A reply falls below the community's threshold of quality. You may see it by logging in.