[Gc] Weak hash tables and cycles

Ludovic Courtès ludo at gnu.org
Mon Nov 3 14:30:17 PST 2008


Is it possible to implement a weak-key hash table that can deal with
cycles using disappearing links?

I'm in particular concerned with the following corner case: K is a key
in a weak-key hash table, V is its associated value, and V references K.
This leads to the following object graph, where the dotted arrow denotes
a disappearing link:

  .---.      .---.
  | K |<-----| V |
  `---'      `---'
    ^          ^
    :          |
    :          |
  |   weak-key   |
  |  hash table  |

Neither K nor V can become unreachable in such a case, even if none of
them is referenced elsewhere.

Thanks in advance,

More information about the Gc mailing list