in reply to Re^14: Why is the execution order of subexpressions undefined?
in thread Why is the execution order of subexpressions undefined?
If your expression contains parts with side effects (changes of "global" variables, reading input from the outside world), then it may depend on execution order. Actually, it only will, if you do read from it more than once. So,
depends on execution order, as does(scalar <FH>, scalar <FH>)
while($i++, $i++)
or(scalar <FH>, $i++)
do not.($i++, $k++)
Expressions with no side effects don't ever depend on execution order. That's one of the basic ideas behind functional programming.
update: It's not always obvious to see when a statement has side effects. Two examples I just recently thought of are rand and the operators .. and ..., which all have a built-in variable holding their current state.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^16: Why is the execution order of subexpressions undefined?
by Anonymous Monk on Apr 16, 2005 at 21:42 UTC |