lua-users home
lua-l archive

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


Hi,

Diego Nehab wrote:
> What is the rationale for this? Why not call
> luai_userstateclose only at the very end?

I guess the best location would be after luaC_freeall() in
close_state(). Because then all GC methods have been run (these
may depend on the userstate) and all threads have been freed
(luaC_freeall() -> luaE_freethread() -> luai_userstatefree()).

Of course the macro must deal with the fact that the main thread
is locked at this point (which makes sense).

A slight complication is that close_state() may be called for an
unsuccessful lua_newstate(), too. And luai_userstateopen() has
not been called in this case.

IMHO something for 5.1.1.

Bye,
     Mike