Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Operator Associative in Perl

by lakshmananindia (Chaplain)
on Jun 03, 2009 at 11:02 UTC ( #767971=note: print w/replies, xml ) Need Help??


in reply to Operator Associative in Perl

From man perlop

Note that just as in C, Perl doesn't define when the variable is incremented or decremented. You just know it will be done sometime before or after the value is returned. This also means that modifying a variable twice in the same statement will lead to undefined behaviour. Avoid statements like:

$i = $i ++; print ++ $i + $i ++;

Perl will not guarantee what the result of the above statements is.

--Lakshmanan G.

The great pleasure in my life is doing what people say you cannot do.


Replies are listed 'Best First'.
Re^2: Operator Associative in Perl
by ikegami (Pope) on Jun 03, 2009 at 15:24 UTC

    Perl doesn't define when the variable is incremented or decremented. [...] Perl will not guarantee what the result of the above statements is.

    While operand evaluation order isn't documented, the order is the same in all versions on all platforms (intentionally), and changing it would break a lot of code.

    perl always evaluates operands from left to right for left-associative operators and exponentiation (**), and from right to left for assignments operators.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2020-02-17 13:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (71 votes). Check out past polls.

    Notices?