Perl-Sensitive Sunglasses | |
PerlMonks |
Re^9: eval order of args to a subby mrpeabody (Friar) |
on Jun 04, 2007 at 10:41 UTC ( [id://619091]=note: print w/replies, xml ) | Need Help?? |
The debug output does demonstrate that, for a specific toy example run on your particular binary, foo() executes first. That's a long way from showing that Perl will behave similarly for all operators and all operands, including tied variables, slow system calls, and threaded applications.
+ - . have "left associativity", so the operands are evaluated in that order; after evaluating the operands for an operation each operation takes place in the order which satisfies said associativity. People might assume that, but it's just not on the page. The snippet we both quoted clearly confines itself to breaking operand-binding ties between adjacent identical operators. On the issue of when to evaluate each operand, the Camel speaketh not. For that matter, you don't even know for sure that foo() will always be evaluated before moo(). Perl could run those functions left-to-right, right-to-left, or all at the same time and still be within spec. It just has to apply the operators in a certain order and finish up before beginning the next statement.
In Section
Seekers of Perl Wisdom
|
|