This explanation is very close. 'C' is very well defined about what is does in terms of statements with lvalues. 'C' is also explicitly ambiguous about what it does with subroutine parameters - in subroutine call, there is NO defined order of evaluation of expressions in the sub call: sub a(expr1, expr2)! C can do expr1 first or expr2 first. Often in C expr2 will be done first because that is the first value that will be pushed onto the calling stack. But there is nothing that mandates that or prohibits a different order. I seem to remember from a discussion with a higher Monk (Ikegami) that Perl always goes left to right, even in a sub arg evaluation, but I also seem to remember that this is not guaranteed by the language spec and therefore I wouldn't count on it.I have to mention that $i=$i++ or in C i=i++ is nonsensical. "i" gets assigned back to "i" and then "i" gets incremented and that value is "thrown away".
In my opinion, a lexically scoped $var is a very cheap thing and should be used if there is any doubt about some subsequent statement. I'm not advocating creating extra unnecessary vars, just ones that "add clarity". | [reply] [d/l] |
| [reply] |