[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Restoring objects

In article <9205281422.AA13547@aristotle.ils.nwu.edu> lynch@aristotle.ils.nwu.edu writes:

   >bill@cambridge.apple.com (Bill St. Clair) writes:
   >What are "weak hash tables", how do they work, and what are they good

   I'll be damned if I can say what they're good for.  I thought it would be
   good for data that would become dated, but then I realized that for
   reliability this would require a GC before each gethash, so that's not
   right...they must be good for something, but what?  There couldn't possibly
   be a useless feature in Common LISP, now could there?  :-)

For better or for worse, Common Lisp does not define weak hash tables.
Apparently, some vendors have added this feature for its
implementational utility.

Offhand, I see two uses of weak references (through a hash-table
interface or otherwise):

- To provide answers to metaquestions about GC.  An example is the
question already cited: "Which instances of class X are still extant
(i.e., not yet garbage-collected)?"

- To permit the use of GC as an audit of data structures.  For
example, true "deletion" of an object A requires nulling out all
references to A.  But let's say an unexpected abort or even a
programming error leaves one or more references still un-nulled.  If
the references are weak, a GC will eventually right the situation.

        Lawrence G. Mayka
        AT&T Bell Laboratories

Standard disclaimer.