[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Does LUA_ENVIRONINDEX make LUA_GLOBALSINDEX obsolete?
- From: Tim Maxwell <timmaxw@...>
- Date: Tue, 15 Jul 2008 08:31:53 -0700
On Mon, Jul 14, 2008 at 10:49 PM, Tim Maxwell <email@example.com>
The environment system is a powerful new feature for Lua. It seems
that the globals table accessible through LUA_GLOBALSINDEX is just
case of the environment table - unless I am mistaken,
simply refers to the environment table that was created for the
state. If I'm wrong, disregard the rest of this message.
Perhaps LUA_GLOBALSINDEX is unnecessary. lua_getglobal and
could be redirected to access LUA_ENVIRONINDEX instead of
Most global variable access should go to the environment table
lua_getglobal and lua_setglobal would be more useful if they want
environment table. Other functions that use LUA_GLOBALSINDEX
go to LUA_ENVIRONINDEX as well.
Can anybody think of a use for LUA_GLOBALSINDEX over
Is there anything that this change would break?
Is LUA_GLOBALSINDEX already being retired?
LUA_GLOBALSINDEX is the environment of the running thread.
LUA_ENVIRONINDEX is useful for sharing an environment across many
userdata/functions in C (especially useful since C functions cannot
share upvalues). Usually, you will want to use LUA_GLOBALSINDEX.
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."
Thanks. I apologize for my uninformed comment.