lua-users home
lua-l archive

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

Thanks Wim, I have (re)read the list messages and Wiki on this subject.
Having created my thread specific global table and __index metatabled it
to the mainthread global table, is the best way to handle the base functions
next(), pairs() etc to simply reexecute base_open() (lbaselib.c) on the new
thread object or is it better to "copy" the baselib functions from the main
lua state to the new lua thread?


David B.

Wim Couwenberg wrote:
> If I have code like

> lua_State* L= lua_create()
> lua_State* L1 = lua_newthread(L1);
>   ...
> lua_replace(L1, LUA_GLOBALSINDEX);

> Does this replace LUA_GLOBALSINDEX in the main thread(L) as well?

No.  Threads have their own globals, but share the registry.