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

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        

Replies are listed 'Best First'.
Re^10: shift in list context buggy? (inconsistencies)
by LanX (Saint) on Nov 12, 2013 at 16:40 UTC
    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.