lua-users home
lua-l archive

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


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

I do exactly the same in most my libraries.

The standard io library does not do this. It sets the file handle to
NULL so that it can issue a "closed file" error message when the user
tries to use an invalid file handle.