Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Autoincrement operator precedence difference between C and Perl

by ikegami (Patriarch)
on Oct 09, 2007 at 07:00 UTC ( [id://643632]=note: print w/replies, xml ) Need Help??


in reply to Autoincrement operator precedence difference between C and Perl

It's not a question of precedence, it's a question of operand evaluation order. For example, precedence dictates the multiplications will occur before the sum in 2*foo()+4*bar(), but it doesn't control the order in which foo() is called in relation to bar().

Operand evaluation order is not defined in either language. Although I'm pretty sure you'll always get the same result in Perl5, you shouldn't rely on it. As for C, it's known to vary between compilers, between platforms and/or due to optimizations. Despite your claim, your snippet is not representative of C.

Don't use and modify the same variable in the same statement.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2026-02-16 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.