[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Accessing the Globals table in Lua5
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 09 Apr 2003 10:25:55 -0300
> 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