[gclist] Guardians
Hans Boehm
boehm@hoh.mti.sgi.com
Thu, 10 Apr 1997 11:18:55 -0700
There are 2 disadvantages in letting the programm choose the finalization
ordering:
1) It's more work. Getting it wrong can be dangerous if finalizers manage
explicitly allocated memory.
2) It relies on global information, which the programmer shouldn't need to
know. If my finalizer for type A objects invokes a method on a type B object it
references, I need to take special precautions if and only if type B objects
also require finalization. I shouldn't have to know that. If B is a character
string represented as a cord (see my previous message), I would have to know
whether a string I use happened to be built out of a sufficiently long file,
and whether any of those characters survived editing, something I really don't
want to know this. The garbage collector already determines the righ kind of
global information.
Hans
--
Hans-Juergen Boehm
boehm@mti.sgi.com