[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hash tables and GC
There is also the rather similar "weak pointer" notion, which I believe is
implemented in T. The operations on a weak pointer are something like:
MAKE-WEAK-POINTER Object => Weak-Pointer
INDIRECT-WEAK-POINTER Weak-Pointer => Object or NIL
Having a weak pointer to an object allows you to keep track of it, but
doesn't prevent GC. Although I haven't ever used either weak pointers or
GC'able hash-tables, I think weak pointers are superior as a language
feature, since they are more primitive and potentially more efficient.
The GC-able hash-table notion unnecessarily complicates the semantics by
rolling in hash-table semantics when the real issue is with GC. Usually
the association capacity of hashtables is unnecessary: instead of
weak-hashing from A to B, allocate another slot in A to hold the weak
pointer to B.
The implementation issues are basically the same as for GC-able
hash-tables, but weak pointers seem to have a sight edge. They can be
implemented by allocating weak pointers in a special area, but given
abundant tag bits, immediate representations are also conceivable.
Rob