Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Autoincrement operator precedence difference between C and Perl

by GrandFather (Saint)
on Oct 09, 2007 at 07:06 UTC ( [id://643634]=note: print w/replies, xml ) Need Help??


in reply to Autoincrement operator precedence difference between C and Perl

This is not a precedence issue, but an evaluation order issue. It is also not a difference between C and Perl, but a "by design" language specification issue that the evaluation order is not specified by either language. It is the same issue that means that the evaluation order of parameters passed to a sub is not specified.

The language specifications are not specific about the evaluation order in such cases to allow compiler/interpreter writers freedom to evaluate such things in a way that best suits their code generators or optimizers.

It is very likely that different C compilers will generate code that produces different results than you have seen. It is even possible that the same compiler will generate different answers when different compiler options are used.

The bottom line is, don't use expressions or parameter lists where execution results are order dependent such as the examples given, or by calling subs that have side effects.


Perl is environmentally friendly - it saves trees
  • Comment on Re: Autoincrement operator precedence difference between C and Perl

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2026-02-16 11:56 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.