On 2/20/07, Robert Dodier <robert.dodier at gmail.com> wrote:
>
> We really should polish the defstruct and/or multiple-assignment stuff
> and merge it into maxima/src.
>
Agreed. In particular, we need to decide what semantics we want. Here are
some corner cases that it might be worthwhile to think about....
The usual expectation is that
[i,j] : [j,i]
will exchange i and j, so assignment needs to be simultaneous. OK. What,
then, about
[i,i]: [2,3]
Is this an error? If not, what value does i get?
Simultaneous assignment should also work for
i: 1$
[i, a[i]] : [2,3] $
which should have the same effect as ( i:2, a[1]: 3 ) and NOT (i:2,
a[2]:3). That means we have to evaluate the LHS for l-value first. But
that is not what happens currently with single assignments. For example,
a:b:[q,r,s]$
a[1] : (a:rest(a))[2];
currently results in a=[s,s], b=[q,s,s], whereas evaluating the l-value
first would leave a=[r,s] and b=[s,r,s].
Maybe this sort of thing is too obscure to worry about, and its OK for
xxx:yyy to behave differently from [xxx]:[yyy].
Side-effects in evaluating the LHS for l-value and evaluating the RHS for
value presumably happen left-to-right, e.g.
i:0$
[ a[i:i+1], a[i:i+1] ] : [ a[i:i+1], a[i:i+1] ]
Is equivalent to
[ a[1], a[2] ] : [ a[3], a[4] ]
right?
That's all for now....
Your friendly neighborhood language lawyer,
-s