[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Order of metatable accesses
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 16 Nov 2020 19:04:10 -0300
> 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.