in reply to $i=$i++
Hi,
the problem is that, basically, this kind of expression does not make sense nor it has a natural value. Post- and pre-increment are special case of the so-called side-effect expression, i.e. expression whose evaluation changes somehow the value of the variables involved.
Now, in C it is said plainly that you must not rely on the order of evaluation of the sub expressions. I remember an example running on an old machine in which the same expression (with side effects) gave a different result when compiled with the native compiler and when compiled with gcc.
IIRC, with perl is the same thing, because the optimizer is allowed to change the order in which your sub expressions are evaluated (except of course when the operator is one of the short-cut ones).
So, never forget the simple rule:
Never, ever, put more than one side-effect expression affecting the same variable into one expression.Cheers
|
|---|