Costas Menico was asking recently on the old Dolphin newsgroup about the
absence of "destructors" in Smalltalk. This question has been asked before
and is a common issue for those with a C++ background when moving to
Smalltalk. Since it is also an issue when moving to most GC'd languages, it
is also an issue for C#, and so Microsoft have written a little article
about "finalization" in C#. This article could well be talking about
finalization in Dolphin Smalltalk.
There are differences in the syntax of course, and the names and objects may
differ. Here are some mappings:
C# -> Dolphin
Finalize -> finalize
System.GC.WaitForPendingFinalizers() -> MemoryManager current
System.GC.SuppressFinalize() -> self beUnfinalizable
Dispose -> free (in both cases only by convention)
The author has missed a way of using finalization to clean up in a
predictable order (at least in Dolphin) which is to use references between
the finalizable objects. If I have two finalizable objects A and B, then if
A references B, A will be finalized before B. These references can be
thought of a "back pointers" to the parent from its children which guarantee
that the parent is not finalized until all the children have been collected.
This idiom is most frequently needed where some resource is used for
allocating and freeing other resources.
Dolphin also has Weak References of course, and the notifications associated
with these can also be used to do a form of finalization, but that is a