[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: wish for 5.2
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 13 Feb 2009 09:40:46 -0200
> > > it would be nice if the __gc entry was on the userdata itself instead
> > > of the metatable..
> >
> > Why? 99% of the time, many objects share the same __gc, so there's
> > little point in bloating userdata to make it per-object.
>
> Plus the __gc method gets the userdata as argument and so you can adapt
> what it does to the object if needed.
e.g., the io library does this when closing files. (It uses the env
field to store the actual closing function.)
-- Roberto