lua-users home
lua-l archive

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


Hi All,
I am trying to understand the intricacies of Lua environments.
In this regard, wiki article by Rici Lake
http://lua-users.org/wiki/EnvironmentTables
was very helpful.

Still, I am struggling to figure out when and how to use
lua_getglobal/lua_setglobal functions.

Here is an example.
Let say, we have C-closure foo. I will change its environmental table
with lua_setfenv. As a result, LUA_ENVIRONINDEX pseudo-index will
reference the new environment table, while LUA_GLOBALSINDEX is not
changed and refers to the "thread environment".
lua_getglobal/lua_setglobal functions use environment table at
LUA_GLOBALSINDEX location and will not see foo's new function
environment.

Am I missing something??

Thanks in advance for your help!
--Leo--