Subject: multiple assignment stuff in src/mlisp.lisp
From: Robert Dodier
Date: Wed, 7 Mar 2007 18:30:47 -0700
On 06 Mar 2007 22:20:58 +0100, Albert Reiner <areiner at tph.tuwien.ac.at> wrote:
> Great! Just one more point I would like to raise:
>
> > (%i18) a : [1, 2, 3, 4];
> > (%o18) [1, 2, 3, 4]
> > (%i19) (i:0, [ a[i : i + 1], a[i : i + 1] ] : [ a[i : i + 1], a[i : i + 1] ]);
> > (%o19) [1, 2]
> > (%i20) a;
> > (%o20) [1, 2, 1, 2]
>
> Here my naive expectation would have been [3, 4, 3, 4], due to the
> following sequence of steps:
>
> - i: 0
>
> - partially evaluate the left hand side of the assignment, giving [
> a[1], a[2] ] and setting i: 2
What is happening is that the right-hand side is evaluated first,
not the left. That is the same as the behavior of assignment at
present:
i:0;
a : [1, 2, 3];
a[i : i + 1] : a[i : i + 1];
a;
=> [1, 1, 3]
not [2, 2, 3] which is what would be the result if the left-hand side
were evaluated first.
I guess this behavior (evaluate rhs before lhs) doesn't bother me
too much, I'd rather just leave it as it is. It's not a consequence
of the multiple assignment stuff.
Thanks for your comments,
Robert