in reply to Re^2: Why does the first $c evaluate to the incremented value in [$c, $c += $_] ?
in thread Why does the first $c evaluate to the incremented value in [$c, $c += $_] ?
I believe this falls into the undefined behaviour of auto increment operator :
Note that just as in C, Perl doesn't define when the variable is incremented or decremented. You just know it will be done sometime before or after the value is returned. This also means that modifying a variable twice in the same statement will lead to undefined behavior.So because of the precedence list, you know the right part will be run first, and the left part after that, but when exactly the variable will be incremented is left to Perl's implementation.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Why does the first $c evaluate to the incremented value in [$c, $c += $_] ?
by Laurent_R (Canon) on Mar 04, 2014 at 22:17 UTC | |
by Eily (Monsignor) on Mar 04, 2014 at 23:04 UTC |
In Section
Seekers of Perl Wisdom