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

Re: Re: Auto-increment frenzy

by rir (Vicar)
on Aug 27, 2003 at 14:12 UTC ( [id://287045]=note: print w/replies, xml ) Need Help??


in reply to Re: Auto-increment frenzy
in thread Auto-increment frenzy

Abigail, I think you misspoke. You are indicating that the addition may precede the increments in your second choice.

Your earlier statement that behaviour is "undefined" is also incorrect. Only the order of evaluation is undefined.

What is known about:

$a + $b
is that both sides will be evaluated before the addition. What is not defined is whether $a or $b will be evaluated first.

In my example it doesn't matter, but if both terms use and alter the same variables then there can be side effects between the terms.

Replies are listed 'Best First'.
Re: Auto-increment frenzy
by Abigail-II (Bishop) on Aug 27, 2003 at 14:21 UTC
    Abigail, I think you misspoke. You are indicating that the addition may precede the increments in your second choice.

    Indeed. That may happen. Post increment means that the variable will be incremented some time between fetching the old value and the end of the statement. It doesn't say it will be incremented before the evaluation of some other operation in the same statement.

    Your earlier statement that behaviour is "undefined" is also incorrect.
    If my statement is incorrect, it must mean that the behaviour is defined. Please define that behaviour for me, quoting the relevant parts of the documentation.

    In my example it doesn't matter, but if both terms use and alter the same variables then there can be side effects between the terms.

    Exactly. Hence, undefined behaviour.

    Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-24 22:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found