lua-users home
lua-l archive

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


Thanks for explaining how lua_setfenv effects threads.
I have a question like the one about threads: is the environment of a userdata used for anything other than user defined purposes?

I've seen how tolua++ uses fsetenv to associate a Lua "peer object" with a userdata, and uses a metatable that delegates to the Lua object. I'm using the same technique with SWIG. But that's all "user defined purposes", not behavior built into Lua. It would be good to know that nothing else in Lua is interacting with the userdata's environment, so I can play with it however I like without anything unexpected happening.

   -Don


Aaron Brown wrote:
David Burgess wrote:

So lua_setfenv() on the thread has the same result as

 lua_replace(L,LUA_GLOBALSINDEX);

Yes, except that the latter can only be done from within the
thread, whereas the former can be done even while the thread
isn't running.