more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
So in the process of getting enlightened about a syntax misunderstanding, I ran across this oddity: First, look at this code and ask yourself what you think it should produce:
No peaking; take a guess first That code produces
Now, I'm pretty sure we all agree that 7 has to be last, and obviously 2 must be printed later than both 3 and 4, and also 5 must be printed later than 6, but what about the rest? It appears that this order is the logical result of perl evaluating &{func }(args ) by evaluating args first, (left to right), and then evaluating func. This strikes me as an odd choice - it goes against the left-to-right evaluation order that perl follows elsewhere. (well, except for if and other control constructs at the end of a statement) Do any monks familiar with language implementation in general have any insight into why things are done that way? Note that an interesting consequence of this is that the following both die with the message "TWO":
--
In reply to surprising backwards evaluation order by fizbin
|
|