However, to provide a general ordering property on finalizers would be quite awkward in GHC - I just can't think of an easy way to do it. [Awkward ways deleted]
If I understand correctly, the problem is that each FP has a cloud of finalizer objects attached to it with no particular structure between finalizer objects and the reason for this unstructured cloud is because you're piggy-backing on some other mechanism.
Actually in the current implementation the finalizers are not attached to the ForeignPtr at all: it's the other way around. This paper explains the details: http://www.haskell.org/~simonmar/papers/weak.ps.gz There's currently no way to get from a ForeignPtr to its list of finalizers (well, you could do a full GC and figure it out). Cheers, Simon
Actually in the current implementation the finalizers are not attached to the ForeignPtr at all: it's the other way around.
Ah, I see. Fortunately, I don't think my sketched implementation depended on such an attachment since it added an attachment of its own. The design is intended to sit on top of the current GHC implementation (i.e., one with Haskell finalizers and no control over the order they are run). A
participants (2)
-
Alastair Reid -
Simon Marlow