[Haskell-cafe] Mistakes in documentation for weak pointers?
Heinrich Apfelmus
apfelmus at quantentunnel.de
Tue Sep 10 20:12:24 CEST 2013
Dear café,
I'm currently studying weak pointers in order to implement garbage
collection for a small JavaScript FFI used by the threepenny-gui library
[1].
While the paper [2] is fairly clear, it seems that the documentation in
System.Mem.Weak [3] 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
correct?
(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?
[1]: http://www.haskell.org/haskellwiki/Threepenny-gui
[2]: http://community.haskell.org/~simonmar/papers/weak.pdf
[3]:
http://hackage.haskell.org/packages/archive/base/latest/doc/html/System-Mem-Weak.html
Best regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
More information about the Haskell-Cafe
mailing list