lua-users home
lua-l archive

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


On Sun, Nov 7, 2010 at 2:26 PM, Gavin Wraith <gavin@wra1th.plus.com> wrote:
> I find myself frequently using it. In Lua 5.2(w5) it can be expressed as
>
>  local x,y, ...
>  do local _ENV = expr
>  x,y, ... = x,y, ...
>  end

Just how does this achieve anything? As I understand it:
1) The first declaration of locals creates some new local variables
with nil contents
2) The new scope and _ENV declaration sets a local variable _ENV for
the next two lines
3) The assignment of "x, y, ..." to "x, y, ..." doesn't do anything,
as each variable exists as a local variable and so _ENV is never
indexed.