lua-users home
lua-l archive

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


Gé,

Gé Weijers <ge@weijers.org>:
> If this C variable is a static or global variable your code is no
> longer reentrant, so you could not use the library with two Lua states
> in your code.

Correct. If this is important, the metatable could be registered using
a dummy global variable pointer (lua_rawsetp) and a pointer to it
could be obtained by yet another API, say lua_rawgetpp = lua_rawgetp
followed by lua_topointer but without touching the stack. No writes to
the global 'variable' are needed, so it can be shared between states.
This does start looking a bit like API creep though (e.g. shall we
also add lua_rawgetip?) but it restores reentrancy and still avoids
name clashes...

Best regards,

-- 
DoubleF