On Mon, Nov 25, 2002 at 04:17:30PM -0800, Yitzchak Scott-Thoennes wrote:
> On Mon, 25 Nov 2002 11:34:23 +0000 (GMT), [EMAIL PROTECTED] wrote:
> >>    $i = 20;
> >>    my($x, $y, $z) = ($i++, $i, $i++);
> >
> >Now, it appears that perl's evaluation order is accident rather than
> >design - so you SHOULD NOT rely on it.  Avoid causing side-effects on
> >variables you use more than once... including the multiple use of shift
> >in assignment.
> 
> This isn't an issue of evaluation order.  In the example above, perl
> evaluates first $i++, then $i, then $i++, placing the results in a
> list.  Then the assignment is done.  The reason $y becomes 22 is that
> the *variable* $i is in the list (by reference, if you will), not the
> *value* of $i.  Only when the assignment is done is the value
> accessed.

Eh, no. In the example above, Perl will evaluate $i three times, and
increment $i twice. It will increment $i the first time after it has
evaluated $i the first time, and the last increment of $i will happen
after the last evaluation of $i. But how exactly the order is of getting
the value of $i and incrementing it is otherwise UNDEFINED.


Abigail

Reply via email to