[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: userdata access after __gc?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 16 Oct 2012 21:00:14 -0300
> 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.