lua-users home
lua-l archive

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


Hi!

One of my sanity asserts in the C api I export to
Lua is that (sengine == L), where 'sengine' is the
lua state originally returned by lua_open() and 'L'
is the state passed as parameter to C functions
called by Lua.

This has usually been a safe assertion, but some recent
insignificant tweaks to my Lua-side code have sometimes
(temporarily!) made (sengine != L) for some calls, so I think
that this assumption is not a good one.  This is Lua 5.0.2.

Under what circumstances might a new lua state pointer
be used?  I don't use threads, but I do use coroutines;
is this symptomatic of a lua->C call from a
coroutine?

Will my original 'sengine' always be good, up until a
lua_close()?  The real reason I'm concerned about this
varying *L pointer is that my lua app registers callbacks
(funcs put in the registry) with the C-side, and then the
C-side calls them rather later.  BUT, the C-side calls
them with the original 'sengine', not the L* at the time
the callback was registered.  Which of the two lua_States
should I use the registry of (I assume this doesn't matter),
but more importantly which of the two lua_States should I
perform the callback with?

Thanks,
--Adam