Subject: Re: Allocating on the stack and *only* on the stack
From: Erik Naggum <erik@naggum.net>
Date: 13 Dec 2000 17:35:39 +0000
Newsgroups: comp.lang.lisp
Message-ID: <3185717739569274@naggum.net>

* Knut Arild Erstad
| I know that closing files is often used as an example of finalization,
| and this makes some sense: if a file descriptor object is being GCed
| while the file is still open, of course you should close it before the
| object is lost.  But IMO it is bad style to wait for the GC to close
| files, in fact I would want the finalizer to issue a warning if it has
| to close the file.

  I think all (scarce) resources should have finalizers associated with
  their allocation request, and that having to relinquish them in the
  finalization code should cause a warning, preferably with a clue as to
  when and where the resource was requested.  This both for safety and
  debugging purposes.

  The main reason not to use finalization for scarce resources, and files
  are a very good example, is that you circumvent error handling in case
  anything goes seriously wrong.  File systems are known to run full no
  matter how big they are.  Network connections may disappear under your
  feet.  Et cetera.  Interactive intervention with hung threads or even
  processes may cause unwind clauses not to be run, and it is unlikely that
  what failed to complete will fare any better in the finalization code.

  This leads me to believe that the finalization code should be system-
  supplied and written to protect the integrity of the system more than
  the application that failed to protect itself, leading to the obvious
  conclusion that really important resources need system support, with all
  the attendant machinery.  This is probably not a new idea, so I'm heading
  for the Lisp machine manuals ...

#:Erik
-- 
  The United States of America, soon a Bush league world power.  Yeee-haw!