lua-users home
lua-l archive

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


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