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

weak pointers vs temporary hash tables



This discussion we've been having keeps going between temporary hash
tables and weak pointers, and the implication of the latter discussion
seemed to be that weak pointers are all you need for temporary hash
tables.  I'm not sure this is so.

For temporary hash tables, special measures need to be taken when a weak
key is GCed.  You can't just set the key slot of the table entry to NIL.
First of all, it would be nice to also nullify the value slot of an
entry whose key is GCed, so that the value can be GCed.  This could be
done by high-level code outside the GC, though.  A more significant
problem is that most hash table mechanisms need to be able to
distinguish never-used table entries from deleted table entries.  Also,
just setting the key field to NIL is no good, because NIL is a valid
key.  The mechanism for invalidating weak pointers to garbage must
therefore be cognizant of the high-level structure containing the weak
pointer.

                                                barmar