[gclist] Guardians

Carl Bruggeman bruggema@ranger.uta.edu
Thu, 10 Apr 1997 11:38:49 -0500


--------
> Why is it that "closing a file" is such a common example of finalisers?

Because they are the most common example of a scarce resource that is
outside of the domain of the program.  If the OS provides an unlimited
number of file descriptors, closing the file isn't important, and you
wouldn't need finalizers (you would just let them all be "closed" when
your program terminated).  Objects that require finalization
encapsulate some state outside of the program that is scarce enough
that each instance must be reclaimed in a relatively timely fashion.

Carl
--------------------------------------------------------------------------------
Carl Bruggeman -- bruggema@cse.uta.edu -- Phone: (817) 272-3600 Fax: 272-3784
Computer Science and Engineering Department -- University of Texas at Arlington