Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!ucselx!bionet!hayes.fai.alaska.edu!accuvax.nwu.edu!anaxagoras!krulwich From: krulwich@ils.nwu.edu (Bruce Krulwich) Newsgroups: comp.lang.lisp Subject: Re: Weak Reference in Common Lisp Message-ID: <1474@anaxagoras.ils.nwu.edu> Date: 23 Aug 90 16:41:52 GMT References: <81084@aerospace.AERO.ORG> <41670@think.Think.COM> <276@paradigm.com> Sender: news@anaxagoras.ils.nwu.edu Reply-To: krulwich@ils.nwu.edu (Bruce Krulwich) Distribution: usa Organization: Institute for the Learning Sciences, Northwestern University, Evanston, IL 60201 Lines: 36 In-reply-to: gjc@paradigm.com In article <276@paradigm.com>, gjc@paradigm writes: >In article <41670@think.Think.COM>, barmar@think.com (Barry Margolin) writes: >> Some Common Lisp implementations ... >> If the only reference to an object is as the key in such a >> hash table it may be removed from the hash table (along with the value) >> and may then be GCed. > >You *have* to mention that that would only be reasonable for EQ hash tables. > >Not for EQUAL hash tables, or any other predicate you can think of. Not necessarily. First of all, the behavior being discussed is only an option and is not correct default behavior in any case. Given this, it's clear that a user may decide that he/she wants this behavior for EQUAL tables as well as for EQ ones. For example, if someone was using EQUAL hash tables to cache computation results in a backward-chaining system (say, mapping propositions onto the leaves of a proof tree that need to be true for the proposition to be true) then the programmer may decide that the savings in computation is only worthwhile in cases when there is no memory tradeoff (i.e., when the structures have to be kept in memory for other reasons already), but when they can be GC'ed then it's worth redoing the computation to keep memory size down. Regardless of whether you agree with my example here (which was a bit off the cuff), it seems clear that this is a feature which would be an option, and not the default behavior, and which a programmer may very well want as an option for non-EQ-based hash tables. Bruce Krulwich Institute for the Learning Sciences