lua-users home
lua-l archive

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


On 12/20/07, Jerome Vuarand <jerome.vuarand@ubisoft.com> wrote:
> Leo Razoumov wrote:
> > I would like to use lua_setglobal and lua_getglobal. These functions
> > use LUA_GLOBALSINDEX.
>
> These are macros. Redefine them to do what you want:
>
> #undef lua_setglobal
> #undef lua_getglobal
> #define lua_setglobal(L,s) lua_setfield(L, LUA_ENVIRONINDEX, (s))
> #define lua_getglobal(L,s) lua_getfield(L, LUA_ENVIRONINDEX, (s))

lua_getglobal/setglobal are standard Lua API documented in Lua
reference manual.
I am reluctant to redefine them in my code.
But I would like to see this change in the next Lua release. After
all, globals come from function environments (i.e. LUA_ENVIRONINDEX).
I think that current definitions of lua_getglobal/setglobal are
artifacts of Lua 5.0 and are not consistent with Lua 5.1.

--Leo--