Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^9: eval order of args to a sub

by mrpeabody (Friar)
on Jun 04, 2007 at 10:41 UTC ( [id://619091]=note: print w/replies, xml ) Need Help??


in reply to Re^8: eval order of args to a sub
in thread eval order of args to a sub

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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-24 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found