[gclist] weak pointer and gc
Richard A. O'Keefe
ok@atlas.otago.ac.nz
Wed, 18 Apr 2001 16:37:16 +1200 (NZST)
Ken Anderson <kanderson@bbn.com> wrote:
The CL implementations i've used, LispM, Lucid, Allegro, CMU
keep symbols forever.
Common Lisp *has* to keep symbols with non-default values for properties
around forever. Suppose a Common Lisp program does
(setf (symbol-value (intern "Great Zot!")) 42)
and then for the next 40 days and nights there are *no* references to the
symbol |Great Zot!| anywhere at all in the program. Lisp must be ready
nonetheless to produce the right value for
(symbol-value (intern "Great Zot!"))
*even though* the symbol was not referenced.
If a symbol has no value (makunbound '|Great Zot!|)
and no function binding (fmakunbound '|Great Zot!|)
and no property list (setf (symbol-plist '|Great Zot!|) nil)
-- or rather, whatever default property list the Lisp uses --
then it may be removed by the garbage collector.
Scheme does not have symbol-value, symbol-function, or symbol-plist,
which gives a Scheme implementor greater freedom.
As far as your XML question goes, i've found that a leaky hash
table for immutable strings works very well. Such a table will
contain the most popular strings at any given time, but the
table can be quite small.
One example of a leaky table would be one that was made completely empty
by the garbage collector.
It all depends on whether uniqueness is simply a space-saving hack or
whether identity (in Scheme terms, the option of using EQ? rather than
EQUAL?) is an essential property.