lua-users home
lua-l archive

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


> So, it would presumably remain cheap to go from having a __gc metamethod to
> having a different __gc metamethod. It could even be cheap to going from
> having a __gc metamethod to not having a __gc metamethod provided the
> finalization code dealt with the missing method case. What would be
> expensive would be gaining a __gc metamethod well after creation? That seems
> fairly reasonable.

Yes. More specificaly, what would be expensive would be going from a
metatable without a __gc metamethod to a new metatable with a __gc
metamethod well after creation. Note that, if you change the metatable
itself, creating a __gc metamethod, Lua could not detect the change (and
so would not run the finalizer). (This would be an incompatibility...)

-- Roberto