[gclist] Buffy finalizer slayer.
Charles Fiterman
cef@geodesic.com
Tue, 15 Jun 1999 07:12:09 -0500
At 04:24 PM 6/15/99 +1000, you wrote:
>On 11-Jun-1999, Charles Fiterman <cef@geodesic.com> wrote:
>> Can you cast a spell to resoul an undead object? Do
>> the resouled undead differ from the living? Can a resouled undead object
>> lose its soul again and does it differ from other undead objects when that
>> happens?
>
>I think your use of emotive language here only serves to obscure the real
>issues.
I was trying to use humorous language and copy the plot twists on Buffy
Vampire Slayer where a vampire is cursed with having his soul back so he
will feel guilt for the evil he has done but loses it again and becomes
even worse than the other vampires but regains it and on and on.
But if there are undead objects, the finalizer put a pointer where it can
be found, it does infect the entire semantics of the language. At minimum
there should be a reflection_in_mirror() method so you can tell if you are
dealing with an undead object that won't run a finalizer. And you need a
heartbeat() method to spot dead objects waiting cleanup as finalizers can
see them even though they are invisible to living objects.
Finalizers corrupt the semantics of a language the way vampires would
corrupt the structure of physics. Why exactly don't they cast reflections
in mirrors? Where does the mass go when they are spiked? Where do they get
the energy for their strength?
Sending out death notices doesn't corrupt the semantics of the language
with at least three kinds of object. The user says "When this object dies I
want notification." And the collector does that, most commonly by zeroing a
weak pointer. What the user does with the notification is the user's
business. If someone wants to provide a topological sort that's great but
if the user can partially evaluate the topological sort in his head while
writing the class definitions that's better. If he can't its a sign of
something seriously wrong with the structure of the program. You should be
able to look at the semantics of watcher objects and very easily what order
they should be in. In most cases order shouldn't matter exactly as Java
says. Where it does matter the order should be trivial, buffers before files.