in reply to Re^2: Order of execution of functions in list
in thread Order of execution of functions in list
FWIW: I think this code is easier to understand and demonstrates your point
I get the same results using the equivalent splice(@_,0,1)DB<194> sub tst { my $x=\(shift()); ++$$x } DB<195> $a=10 => 10 DB<196> tst $a => 11 DB<197> tst $a => 12 DB<198> $a => 12
That's not documented in the perldocs for shift or splice and I think it's due to the way Perl holds and replaces variables in @_, they just don't loose their aliasing magic when shifted.
Maybe Perl avoids copying of the values for performance reasons.
Interesting...
But since it's not documented, I doubt that this is reliable behavior.
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Order of execution of functions in list
by ikegami (Patriarch) on Sep 16, 2013 at 02:08 UTC | |
by Anonymous Monk on Sep 16, 2013 at 03:12 UTC | |
by ikegami (Patriarch) on Sep 20, 2013 at 18:25 UTC |