lua-users home
lua-l archive

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

> 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).

> That is, will a global variable that held the userdata for which the __gc 
> handler is currently being called still be accessible "normally" as in any 
> other C callback?


> 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.)

-- Roberto