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

Re: Restoring objects



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

   >What are "weak hash tables", how do they work, and what are they good
   >for?

   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?  :-)

Weak tables or weak pointers (as they were called in T) are useful if
you want to maintain your own collection of data structures for
possible reuse. Suppose I have a data structure called the "match
result". If I'm doing a lot of matching I might want to save old match
results, clear them out and reuse them instead of consing up new ones
all the time. I would maintain my own list of the old ones. This turns
out to be useful for space efficiency, but it's nice to be able to
respond when the system needs more memory by freeing these things up
since they can always be recreated. 

Obscure, but not useless. I think there are better candidates for
useless features in Common LISP.


--
robin
=:-{)

institute for learned scientists
northwestern university