Heinrich Apfelmus | 10 Sep 20:12 2013
Picon

Mistakes in documentation for weak pointers?

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."

(Continue reading)


Gmane