[gclist] weak pointer and gc

Richard A. O'Keefe ok@atlas.otago.ac.nz
Thu, 19 Apr 2001 14:33:19 +1200 (NZST)

I wrote (referring to Common Lisp) that
	 > 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.
Raymond.Wiker@fast.no replied

		I don't think so. The symbol *still* has an identity, which
	may be required somewhere.  Further, the package structures keep
	references to interned symbols (either explicitly, via intern,
	or implicitly, through reader operations.)

"may be removed by the garbage collector" means, of course
"may be removed by the garbage collector like any other object,
 when there are no references to it."  The paragraph quoted was in
the context of a discussion about when/whether a symbol WITH NO
REMAINING REFERENCES TO IT may be garbage collected.
"The package structures" here are precisely the symbol table,
and the point at issue was whether the symbol table (in fact, a Scheme
symbol table) MUST retain symbols or can/should use some kind of
weak references.

If there are no remaining references to a symbol, then there can be
nothing that depends on its identity.  Deleting it, and creating a new
symbol with the same name the instant someone cares, cannot change the
behaviour of any Lisp code.  An object that disappears when no-one is
looking and reappears when they do is very like an object that is
simply _moved_ by the garbage collector.