From: Steve Knight
Subject: Re: Weak Reference in Common Lisp
Date: 
Message-ID: <1350026@otter.hpl.hp.com>
Niels Mayer asks:
> Does anybody have any pointers to articles on this subject? What do weak
> references buy you? How do they affect performance? Why do you want them?
> How do you use them?

Although Common Lisp does not provide a standard mechanism for implementing
weak references, some implementations provide hash-tables in which the
entries can be garbage collected when the key or value or either becomes 
garbage.  These can be used to implement weak references.  In Pop11 they
are called "temporary" properties.  I believe they are called "populations"
in Scheme.  

They have a number of uses.  The simplest use is attaching information to
data structures without having to declare extra fields in the data structure.
Temporary properties allow you to do this without making the data structures
permanent.  Another typical use is for sparse information, such as sparse 
arrays, in which considerable memory savings might be made.  Sometimes they
are useful to provide ways of iterating over all members of a set without
making the members of the set permanent.  

For implementations (such as Poplog Common Lisp) in which it is possible to
mark entries as garbage collectable if either key or value becomes garbage,
it is convenient to represent two-way relations without nasty store
implications.

The cost of temporary properties is to make the garbage collection
algorithm slightly more complicated & to necessitate rehashing after GC.  
These are typically small costs.

I hope these quick comments are useful.

Steve Knight