[gclist] Destructor FAQ

Chris Reedy creedy@mitre.org
Fri, 15 Mar 1996 12:52:05 -0500


At  9:56 AM 3/15/96 -0500, Robert A Duff wrote:
>> Here I don`t see how an already finalized object has a usable state.
>> A finalized file object is closed. That may be well defined but
>> using it is a problem. Perhaps we could distinguish between finalized
>> objects left in a usable state and those left in a useless state.
>> This would allow simplification of finalization dependencies for
>> the former but not the later.
>
>It's true that writing to a closed file is a bug.  That's true with or
>without finalization.  It's the programmer's responsibility to make sure
>it doesn't happen.  [... other stuff]

This comment bothers me.  I could just as well say that it's the
programmer's responsibility to make sure that they don't use pointers to
discarded data and to make sure that all allocated memory is released when
it is no longer needed.  However, one of the reasons I would like to use GC
is that experience has shown that it can be extrememly difficult for the
programmer to ensure that he has correctly done these things which are his
"responsibility".  Further, we also know that when the programmer does not
do this correctly, a program will tend to fail in strange and arcane ways
that are difficult to track back to the original source of the problem.

It seems to me that ordering of finalization falls in the same category. 
The last thing I want to have to do is to try to find a bug relating to the
fact that sometimes, probably depending on a lot of factors over which I
have no control, my program fails in finalization because I'm writing to an
already closed file.  And, as a programmer, what approach do I use to
guarantee that the file will not be closed before I have a chance to flush
the buffers.

  Chris

This is an informal message and not an official Mitretek Systems position.
Dr. Christopher L. Reedy, Mail Stop Z667
Mitretek Systems, 7525 Colshire Drive, McLean, VA 22102-3481
Email: creedy@mitretek.org  Phone: (703) 883-7183  FAX: (703) 883-6991