Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Order of execution of functions in list

by LanX (Canon)
on Sep 13, 2013 at 17:02 UTC ( #1053967=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Order of execution of functions in list
in thread Order of execution of functions in list

> > returns an rvalue

FWIW: I think this code is easier to understand and demonstrates your point

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
I get the same results using the equivalent splice(@_,0,1)

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)


Comment on Re^3: Order of execution of functions in list
Select or Download Code
Re^4: Order of execution of functions in list
by ikegami (Pope) on Sep 16, 2013 at 02:08 UTC

    But since it's not documented, I doubt that this is reliable behavior.

    It's an emergent behaviour; it's not by design.

      It's an emergent behaviour; it's not by design.

      What's that mean (important why)?

      It goes back far enough (5.8 at least) and its in t/op/sub_lval.t update: since 2001

      so it emerged? long ago :)

      OTOH, a reference to an alias takes a reference to the original and incrementing tat referenced value increments the original -- can't see any aliasing magic being preserves, references reference

        To design something means you've chosen how it behaves. If something is not the result of design, it means noone chose to have it behave in that particular fashion. The behaviour merely emerged. This means no analysis of the behaviour was performed, so it may not be a desired behaviour.

        so it emerged? long ago :)

        Sure, but not necessarily relevant.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-10-23 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (126 votes), past polls