[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: does the current environment revert automatically?
- From: Norman Ramsey <nr@...>
- Date: Fri, 21 Dec 2007 18:02:06 -0500
> - uses of lua_replace(L, LUA_ENVIRONINDEX) weren't designed to be
> nested, so if you want that you need to save and restore it yourself
>
> - use lua_replace(L, LUA_ENVIRONINDEX) followed by luaL_register()
> and then, if you are paranoid about leaking your environment, as I am,
> use lua_pushnil(L); lua_replace(L, LUA_ENVIRONINDEX) to hide it
Hmm; good plan. But save and restore is not much more work:
lua_pushvalue(L, LUA_ENVIRONINDEX); /* save */
... stuff that messes with the environment
lua_replace(L, LUA_ENVIRONINDEX); /* restore */
N