lua-users home
lua-l archive

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


On Thur,2011-12-29,Xavier Wang <weasley.wx@gmail.com> wrote﹕
>I have looked into Lua5.2's module's implement, it has a C function
>set_env, but this function only changed the value of the first upvalue
>of current function. So if we call module in a function, not in a
>file, it will be confused.
> 

The set_env function may only work when the caller lua function has only one upvalue, _ENV. As the description of lua_getupvalue seems tell me that the order of upvalue is arbitrary. If there are more upvalues _ENV may not be the first one.