[gclist] Finalization and death notices

Greg Colvin gcolvin@us.oracle.com
Sun, 7 Oct 2001 16:33:21 -0600

From: Hudson, Rick <rick.hudson@intel.com>
> .... So after years of trying
> to make finalizer semantics work I've come to believe that they are just
> simple a bad idea. Death notices seem more practical and have the potential
> to be semantically cleaner and result in simpler languages.

It does seem that no collection/finalization scheme can meet Charles'
desiderata: Finalizers must be safe, general, sure and ordered.

One way out is to give up on "general", and perhaps "ordered" and
impose restrictions on finalizers to ensure safety.  As I noted,
it is already the case that throwing an exception from a C++
destructor is unsafe, so there is precedent there for restricting
cleanup operations.  It wouldn't bother me if optaining locks in
cleanup functions were also unsafe.  Different restrictions might
be appropriate in other languages, but the idea that the only thing
a cleanup function should do is release resources seems appropriate
to me.

The death notice idea has it's attractions as well, as it makes
possible the promise that garbage collecting the memory of a
correct C++ program will not break the program.