lua-users home
lua-l archive

Re: Per-value metatables would be great for threads

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


> Was there near-universal acclaim for per-value metatables,
> or am I just remembering what I like to? Anyway, pointing out
> one more advantage can't hurt :-)
I originally proposed that in jest. (The light userdata part was
serious, but the "(We could even gain individual metatables for numbers
:-)" was intended as a joke...
> When a coroutine goes dead, there is often some finalizing to do.
> Setting a return hook in order to call a finalizer looks kludgy.
> The neat way is a __gc metamethod.
As someone already pointed out, "value metatables" cannot work for
finalizers. An object is collected when there are no more "values"
pointing to it; in that case, its metatable will be no longer
accessible...
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /