Alastair wrote:
I seem to remember that Sigbjorn and Erik dealt with this problem by arranging some kind of GC-visible link between the objects so that until the second finalizer has run, the object will not be considered garbage.
Sorry, this was nonsense - I hadn't noticed that is was a single ForeignPtr (in Haskell land) as well as being a single object (in C land). Seems like it'd be reasonable to specify an order for these. An alternative would be to drop addForeignPtrFinalizer. I have no idea what the motivation for this function is since I can't think when you'd need/want/prefer to add finalization actions incrementally instead of doing it in one step. Can someone give a motivating example where there is some advantage in adding finalization actions incrementally? -- Alastair