lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


 > - 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