[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Replacing LUA_GLOBALSINDEX when porting 5.1 libs to 5.2...
- From: Peter Cawley <lua@...>
- Date: Mon, 31 May 2010 09:54:00 +0100
On Mon, May 31, 2010 at 9:03 AM, duck <duck@roaming.ath.cx> wrote:
> Can this 5.1 code:
>
> lua_getfield(L, LUA_GLOBALSINDEX, name);
>
> be made ready for 5.2 by writing this instead:
>
> lua_pushglobaltable(L);
> lua_getfield(L,-1,name);
> lua_remove(L,-2);
5.1 and 5.2-work3 both define a macro called lua_getglobal(L, name),
which seems the easiest choice here. That said, it expands to your 5.1
code under 5.1, and to your proposed code under 5.2.