[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Order of metatable accesses
- From: "Soni \"They/Them\" L." <fakedme@...>
- Date: Mon, 16 Nov 2020 19:22:48 -0300
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
> %luac -p -l a
> 1  GETTABUP 0 0 -3 ; _ENV "c"
> 2  GETTABUP 1 0 -4 ; _ENV "d"
> 3  SETTABUP 0 -2 1 ; _ENV "b"
> 4  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 :)