[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: about objects freeing tagmethod resources, etc
- From: "John Belmonte" <jvb@...>
- Date: Thu, 9 Nov 2000 22:57:44 +0900
Recently there was a discussion about the removal of table gc events from
4.0.
I agree that destructors aren't needed in most cases for a language with
garbage collection. However one unavoidable case is when it's necessary to
free some system resource (other than memory) claimed at object
construction. Lua has at least one such resource: tag methods. Without a
notification that my table object was collected I cannot undo any tag
methods I set up within the object's constructor (that is, per-instance),
which means that the tag methods themselves can never be garbage collected.
It would be nice if Lua had support for weak references. For example if
there was a "weak table" that doesn't count as a reference for the objects
it holds, and that gets a callback when one of its fields becomes nil. This
avoids the issue that the table gc events had because it's not possible to
"re-reference" an object.
-John