lua-users home
lua-l archive

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


Hi All! ,
I'm not sure to completely understand the purpose of the LUA_ENVIRONINDEX pseudo index. This is new to lua 5.1 and is the pseudo index to access the environment of the running C function. Ok, is this the global table of the running C function ? is by default the same as the LUA_GLOBALSINDEX if not changed by a lua_setfenv ? Should we use it by default instead of LUA_GLOBALSINDEX (it is more correct to try access the current environment)? is LUA_GLOBALSINDEX a way to always access the thread environment ignoring a lua_setfenv ?

Can anybody give an example where the lua_environment is useful, or an example where lua_globalsindex can not be used? For example, could lua_environindex be used to hold data locally( or private ) to a C function that can be accessed in successive calls?

Thank you!

   PpluX