lua-users home
lua-l archive

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



On 2020-11-16 7:04 p.m., Luiz Henrique de Figueiredo wrote:
> > But the only thing I see in the
> > manual is "The assignment statement first evaluates all its
> > expressions and only then the assignments are performed." Should the
> > manual make a stronger statement, or is what it says all that's
> > guaranteed and the other ordering I noticed just an implementation
> > detail?
>
> Which other ordering? It works as advertised: if evaluates c.baz and
> d.qux before assigning to b.bar and a.foo.
> Oh, you mean the order of the assignments are performed? The manual
> purposely avoids saying anything about this; it's just an
> implementation detail.
>
> You don't need a complicated example. Here is a simpler one:
>
> % cat a
> a,b=c,d
> %luac -p -l  a
> 1 [1] GETTABUP 0 0 -3 ; _ENV "c"
> 2 [1] GETTABUP 1 0 -4 ; _ENV "d"
> 3 [1] SETTABUP 0 -2 1 ; _ENV "b"
> 4 [1] SETTABUP 0 -1 0 ; _ENV "a"
>
> which reads: getblobal c, getglobal d, setglobal b, setglobal a.

"hmm this looks like it'd cause issues with <close>"

$ luac -l -l -o /dev/null -
local a <close>, b <close> = c, d
luac: stdin:1: multiple to-be-closed variables in local list

well then, nvm :)