lua-users home
lua-l archive

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


> 1. Has Lua been fixed to call the gc metamethod for tables as well as for
> userdatas?
Nope.

> 2. If the answer is no and there is no plan to, then where does one send
> feature requests/explanations (other than to this list)?
This is definitely the best place; the authors are very involved in the list. 

> A. All the other metamethods work for tables as well as userdatas, why the
> goofy exception?

This is my explanation, and I don't speak for the authors, but here's what I've
always assumed: Userdata finalizers are there because the resources used may
have completely arbitrary finalization semantics (for instance, the userdata may
be a struct holding a pointer to dynamically allocated memory). The finalization
semantics for tables, in comparison, are simple: References to all keys and all
values, and to the table's metatable, are removed. So it isn't so much "goofy"
to not have a table __gc metamethod, as it is for userdatas to need one.

In your case, the simplest way I can see would be for the userdata stored in the
table to contain whatever information is needed for finalization.

Hope this helps.

Ben