Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!uunet!mcsun!ukc!edcastle!aiai!jeff From: jeff@aiai.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.lisp Subject: Re: Weak Reference in Common Lisp Message-ID: <3289@skye.ed.ac.uk> Date: 27 Aug 90 14:41:43 GMT References: <81084@aerospace.AERO.ORG> <1350026@otter.hpl.hp.com> Reply-To: jeff@aiai.UUCP (Jeff Dalton) Organization: AIAI, University of Edinburgh, Scotland Lines: 32 In article <1350026@otter.hpl.hp.com> sfk@otter.hpl.hp.com (Steve Knight) writes: > >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. T (A dialect of Scheme) has populations. I don't know of any other Scheme that does. A polulation is what is sometimes known as a "weak set". It's isn't a mapping from keys to values, just from objects to true or false (depending on whether or not the object is in the population). T, and perhaps some other dialects of Scheme, have an operation called object-hash that returns a weak pointer, plus object-unhash for going back from a weak pointer to the corresponding object. Lisp/VM had hash tables that were weak for (I think) one of either keys or values (I forget which). I happen to prefer the hash table approach over that of explicit weak pointers. I also think Pop11 is right to allow hash tables (called "properties") to be used as functions and to allow programmers to specify their own test and hash functions. Moreover, I think hash tables in Common Lisp are much less useful than they ought to be, because putting something in a hash table prevents it from being garbage collected. -- Jeff