lua-users home
lua-l archive

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

05.10.2011, 14:27, "Luiz Henrique de Figueiredo" <>:
>>  Why does load(...) in 5.2 make an assumption, that _ENV is *always*
>>  first upvalue? I think it should search for the name "_ENV" instead
>>  (and set nothing, if not found).
> Upvalue names may not be available of debug information has been stripped.

Aww, thanks.. I didn't know about stripping.

So, please correct me, if I am wrong. To properly change environment
of Lua function, that function should in general follow "_ENV is first
upvalue" protocol. This is only guaranteed for newly compiled chunks,
i.e. load() with source string argument, and not for string.dump'ed or
other arbitrary chunks.

-- Artur