[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: bug report: LUA compiler glitch
- From: Mike Pall <mikelu-1108@...>
- Date: Wed, 10 Aug 2011 01:26:33 +0200
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
manual.
But it neither guarantees a particular *evaluation order* for the
right-hand side, nor a particular *assignment order* for the
left-hand side.
[
More than you ever wanted to know about this topic can be found
in my message that triggered the clarification from Roberto:
http://lua-users.org/lists/lua-l/2006-06/msg00376.html
]
> Which means that this:
>
> os.execute_without_echo, os.execute = os.execute, os.execute_with_echo
>
> Will either work or not, arbitrarily (it does seem to work in 5.1.4).
It always works, because the expression results of the right-hand
side are stored in temporaries before doing the assignment.
[Actually, the Lua parser avoids the temporaries if it finds no
conflict between the two sides. It doesn't do that for your
example, of course.]
--Mike