in reply to Pre vs Post Incrementing variables
What's the logic behind that?
The logic is that if you don't define strict rules for order of execution within statements, you have some potential for optimizations.
This was particularly important for C, where assembler level statement re-ordering was (and maybe still is) an important optimization technique. I don't know how much perl 5 benefits from this freedom, if at all.
Curiously we had a similar discussion in #perl6 the other day, and it turns out the Perl 6 specification defines sequence point operators within statements which synchronize evaluation. That means that on the right-hand side of such an operator you can rely on changes to variables made on the left-hand side.
But in general it's much safer to use a variable only once in a statement where it's modified.
|
---|