lua-users home
lua-l archive

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


>  Is it also true that a reference to the globals table can be pushed
> on the top of the stack by using lua_pushvalue(L, LUA_GLOBALSINDEX)?
> If so is this worth mentioning in the documentation? If not I can not
> currently find a way of enumerating the globals table.

Although it is correct to use lua_pushvalue(L, LUA_GLOBALSINDEX) to
push the global environment on the stack, you do not need this to
traverse it. As already answered, you can use LUA_GLOBALSINDEX as an
index in any call that asks for an object. So you can call
lua_next(L, LUA_GLOBALSINDEX) directly.

-- Roberto