lua-users home
lua-l archive

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

Dear Robert,

Roberto Ierusalimschy wrote:
when a call to lua_close() triggers calls to the the __gc handlers/callbacks, in what condition is the Lua state (given as the lua_State* parameter to the __gc handler) at that time?

Calling the finalizers of all userdata is the first thing done by
lua_close. So, the state should be as it was just before the call
(except for the modifications done by the finalizers themselves).

Thank you very much for the quick reply / clarification!

More importantly, if there is *another* userdata instance as a value in the globals table or in the registry, and I overwrite it by assigning nil to the same index, is that a valid operation to do in the __gc handler?

Yes. (The finalizer of this other userdata will be called anyway, if it
was not called already.)

Yes, I guessed that, just wanted to make sure that my "unanchoring" of userdata (nil assignments) has no ill side effects.


Multi-Player, Multi-Platform, Real-Time 3D Action