Re^3: shift on empty array in list context broken
by tybalt89 (Monsignor) on Jul 13, 2019 at 21:30 UTC
|
splice lied! It's almost sort-of nearly true, but not completely true :)
| [reply] [d/l] |
|
|
splice didnt lie
The array is manipulated exactly like shift would manipulate it.
The return value is exactly as documented for splice/shift.
The equivalences chart is part but not the whole documentation.
| [reply] |
|
|
| [reply] |
|
|
|
|
|
|
|
| [reply] |
Re^3: shift on empty array in list context broken
by tybalt89 (Monsignor) on Jul 13, 2019 at 21:38 UTC
|
my @x = ();
my $x = splice @x, 0, 1;
What splice says is true in scalar context.
| [reply] [d/l] |
|
|
DB<17> ($x= splice @x, 0, 1 ) and print "true"
DB<18> p !! splice @x, 0, 1
DB<19>
it's false for me.
| [reply] [d/l] |
|
|
I believe that, by "What splice says is true in scalar context.", Tybalt meant "in scalar context, the documentation for splice holds true", not "in scalar context, splice returns a truthy value".
| [reply] [d/l] [select] |
Re^3: shift on empty array in list context broken
by ikegami (Patriarch) on Jul 15, 2019 at 11:17 UTC
|
That should be fixed. Feel free to use perlbug to submit a bug report. Please include a suggested fix.
| [reply] [d/l] |
|
|
Reported without a precise suggestion to fix.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
| [reply] [d/l] |
|
|
| [reply] |
|
|
Re^3: shift on empty array in list context broken
by Don Coyote (Hermit) on Jul 21, 2019 at 14:08 UTC
|
DB<232> x $x=4; while( ($y)= ( $u = splice( @t,0,1 ))){ last unless
+$x--; print ":$_: " }
:: :: :: :: empty array
which would make the equivalence:
shift(@a) === ( $t = splice( @a,0,1 ) )
| [reply] [d/l] [select] |