[Haskell-cafe] Mistakes in documentation for weak pointers?
apfelmus at quantentunnel.de
Tue Sep 10 20:12:24 CEST 2013
I'm currently studying weak pointers in order to implement garbage
While the paper  is fairly clear, it seems that the documentation in
System.Mem.Weak  differs in certain aspects. Could someone help me
and clarify this? I have two questions:
1. The sentence in the documentation
"References from the finalizer to the key are treated in the same way as
references from the value to the key: they do not keep the key alive."
seems incorrect in the subordinate clause. Namely, the paper only states
that the weak pointer object does not keep the key alive. However, I
understood that it is perfectly acceptable for the value to keep the key
alive, and that this relation is not changed by mkWeak . Is this still
(The memo table example in the paper never stores the value itself, only
a weak pointer to it, so it doesn't matter whether the value is
reachable from the key or not.)
2. The sentence in the documentation
"A heap object is reachable if: ... It is a weak pointer object whose
key is reachable."
seems to differ from the paper, which states that while weak pointers
are always retained if their keys are alive, they can very much be
unreachable. But if I think about it, the formulation in the
documentation seems to be equivalent to the paper (as far as the
semantics are concerned, it does not matter whether unreachable weak
pointers are tombstoned or not.). Is that correct?
More information about the Haskell-Cafe