lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> From: Mike Pall <>
>Ross Andrews wrote:
>> By "order of assignment is undefined", does it mean that the order in which
>> values are put in variables is undefined, or the order in which the
>> right-hand side is evaluated is undefined?

>Actually both. The parallel assignment statement only guarantees
>that all expressions on the right-hand side are evaluated before
>any of the assignments are made. See section 2.4.3 in the Lua 5.1

>But it neither guarantees a particular evaluation order for the
>right-hand side, nor a particular assignment order for the
>left-hand side.


I like to emphasize a point, and this is the definition of pairwise
binding, which is not covered by any of the responses.

Say one has ''function foo(a,a) return a end'' calling ''foo(1,2)'' will
return correctly ''2''.

Now ''let a,a = 1,2'' will produce an environment with ''a=1'' because
of the glitch.

While both variables have the same name, they are different, really,
and the assignments should be pairwise like in the function call.

The glitch confuses both variables, not only breaking the order
of side effects (sorry, if disagree I here, that leaving this undefined
is not good thing) but also the order binding in variable introduction.
If pairing in binding is additionally undefined, then please what is?