> | - in GHC, references from a finalizer are treated as weak
> | references, that is, they don't keep anything alive. In our
> | paper on weak pointers I seem to recall there was a good reason
> | for this, but I'll need to go back and look it up again. I'm
> | beginning to think the decision seems a bit odd (after all, in
> | the next GC, the references become non-weak again, because the
> | finalizer is up and running).
>
> There's a good reason for this: otherwise the finaliser would
> keep alive the very object whose death it is watching for.
Sorry for not being more explicit: I should have added that the
alternative solution I had in mind was to pass the object as an argument
to the finalizer. Clearly the finalizer needs to get access to the
finalized object, but there also seem to be cases where the finalizer
should be able to reference other objects in a non-weak way, so as to
impose an order on finalization. Of course if you do ordering this way,
then it takes N full GCs to fully finalize a dependency chain N deep (at
least in our implementation).
I took a look through our weak pointer paper, and I can't see any
problem with changing finalizers so that they take the key (and maybe
the value also) as an argument, and treating finalizers essentially as
roots in the GC, until they have started running.
Cheers,
Simon
_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc