lua-users home
lua-l archive

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

On Tuesday 16, Josh Haberman wrote:
> Looking at the reference manual, this is not explicitly promised, so
> maybe it's just the responsibility of the __gc method to mark the object
> destroyed, and for all other functions that operate on the userdata to
> check that it is not already finalized?

The way I handle this is to set the userdata's metatable to nil in the 
__gc/close methods, then it's not possible to call any method on the finalized 
object.  So there is no need to add extra checks to all the other methods, 
just the normal type checking.

Robert G. Jakabosky