On 26/03/07, Nicholas Clark <nick@ccl4.org> wrote:
> Assuming the same opcode layout.
>
> Currently the execution order for state $a = $b is
>
> $b
> $a
> =
>
> isn't it?
>
> If, instead, assignments where the entire LHS is state variables compiled to
>
> state check on $a:
> $b
> $a
> =
>
> then the RHS would only be evaluated if $a needed assigning to, and also the
> assign op wouldn't need the flags any more.
That's an interesting idea, although it needs a new op "state check"
and heavy manipulation of the optree in the ck_ routines.
But looking at the ops at this way, I just found a new bug :
$ bleadperl -E 'sub f{say state$x=42;++$x;say $x}f;f'
42
43
42
44
The return value of a state assignment is the right hand side. (but
the actual assignment happens only once, correctly)
Thread Previous
|
Thread Next