[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Replacement for luaL_openlib in Lua 5.1
- From: David Burgess <dburgess@...>
- Date: Sat, 3 Dec 2005 13:46:34 +1100
On 12/3/05, Rici Lake <lua@ricilake.net> wrote:
>
> As far as I know, lua_replace will not work with the LUA_ENVIRONINDEX
> pseudo-index, [...]
This can be done, as it is in loadlib.c and liolib.c. It requires that the
C function that is doing the lua_replace has its own lua stack (i.e. has
been lua_call()ed). I do not understand why.
So,
> =_G
table: 00323E68
> =debug.getfenv(io.stdout)
table: 003260A8
> =debug.getfenv(io.read)
table: 003260A8
> =debug.getfenv(getmetatable(io.stdout).read)
table: 00323E68
> =package
table: 00328A98
> =debug.getfenv(package.loaders[1])
table: 00328A98
> =debug.getfenv(package.loadlib)
table: 00323E68
So we see that the io. functions and package.loaders run in an
environment installed with lua_replace. (However, I dont understand
why the loaders do this).
DB