[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Deep __newindex on assignment?
- From: Tom N Harris <telliamed@...>
- Date: Sat, 26 Dec 2009 16:23:19 -0500
> It is another issue: one cannot distinguish between assignments
> *intended* to create a new or change an existing variable. (see also
> http://spir.wikidot.com/create-vs-change, esp. section "things &
Right. Lua aims for simplicity by only providing one interpretation of
the '=' operator: assign an existing value to a variable. It's the
right-hand side of the expression that does all the object creating. The
left-hand side is only binding the value to a key in a table. And local
variables are keys in a "table" that gets optimized away by the compiler.
As for "creating" variables, there is no such thing. All possible
variable names exist by default and are assigned the value 'nil'.
The upshot of all this is that values live independently of variables.
In-place operators look sexy as syntax, but does it make a difference to
the VM? I'm not sure it does.