lua-users home
lua-l archive

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


> For one of my projects I need to reliably change the environment of a function*
> While doing some experimenting to see how this could best be done in a way
> that works in both LuaJIT and 5.3, I came across the following behavior:
> 
> [...]
> 
> As you can see, if a normal upvalue is used before any "global" variable, _ENV
> is not the first upvalue. While the reference manual doesn't really state that
> _ENV has to be the first upvalue, the load function does seem to assume this
> and while digging through the archive, there was another thread where everyone
> seemed to be taking it for granted that _ENV is always the first upvalue.
> 
> Is this supposed to behave like this, or is it a bug? [...]

There was a recent discussion about this topic in the list, starting
with

  http://lua-users.org/lists/lua-l/2018-08/msg00111.html

-- Roberto