[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LUA_ENVIRONINDEX, LUA_GLOBALSINDEX and lua_getglobal/lua_setglobal
- From: Doug Currie <doug.currie@...>
- Date: Wed, 19 Dec 2007 14:31:32 -0500
On Wednesday, December 19, 2007 Leo Razoumov wrote:
> 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??
Assuming there is a table stored in the C closure's environment, to
store a value in the table:
lua_pushliteral (L, "somevalue"); /* value to store */
lua_setfield (L, LUA_ENVIRONINDEX, "somekey"); /* key */
and to retrieve it
lua_getfield (L, LUA_ENVIRONINDEX, "somekey");
e
--
Doug Currie
Londonderry, NH, USA