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

Hash Tables and GC

   Add a keyword parameter :TEMPORARY to MAKE-HASH-TABLE.  If this
   argument is specified and not NIL, and if :TEST is #'EQ or #'EQL,
   entries in the table may be removed by the GC if the key (i.e.,
   an object EQ or EQL to the key) IS ACCESSIBLE ONLY THROUGH THE
   TABLE.  Entries in EQUAL tables are never so removed, nor are
   numbers in EQL tables.  [Explanation: in these cases, it is
   generally possible to construct new objects that are respectively
   EQUAL or EQL to the key.]

Numbers and Characters could never be removed from EQL tables, because
they ARE always accessible in other ways.  But what is the rationale for
PROHIBITING the removal of an entry from an EQUAL hash table if its
key is in fact accessible ONLY through the table?  E.g., defstruct
instances and symbols can be legitimately used as keys in an EQUAL hash
table, so an implementation that removed them from EQ hash tables
would be able to remove them from EQUAL tables as well.  Note that
all discussions of this topic have considered an implementation correct
even if it NEVER removed entries, and I don't recall anyone implying
that an implementation that did remove entries was required to remove
ALL removable entries.

Also, the think the proposal should explicitly state that
a TEMPORARY hash table. (Alternatively, the proposal could state what
useful behavior can be relied on for these functions with
temporary hash tables.  For instance, they could map over / count all
the non-garbage entries as well as whatever gargage entries had
not yet been collected.  But would that be useful?)