lua-users home
lua-l archive

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




On Mon, Nov 19, 2018 at 12:19 PM Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
When dealing with userdatas in particular, it can be useful to reset the
metatable in the finalizer to nil or to a dummy metatable, because there
is a specific case where the object is _NOT_ unreachable after the
finalizer returns [...]

I just figured that out, so it does make sense to remove the metatable if your finalizer leaves your object in an unsafe state otherwise. I typically have an explicit method that releases the resources used by a userdata object (object:close() or similar), so I don't particularly care about accesses via an ephemeron table.

Thanks,

--
--