[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: userdata access after __gc?
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Tue, 16 Oct 2012 16:05:20 -0700
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