[Haskell-cafe] Finalisers

Thomas Schilling nominolo at googlemail.com
Wed Nov 26 19:07:26 EST 2008


Possible, yes.  Advisable, no.

There is no guarantee that the finaliser is ever run, they are
expensive (since they need to be kept separately and checked after
each GC) and there are easier methods.  Lava [1] uses a very
lightweight sharing detection mechanism.  Depending on your problem
you might also want to look at Oleg's approach to explicit sharing in
a DSL [2].

 [1]: http://www.cs.chalmers.se/~koen/Lava/papers.html
 [2]: http://www.mail-archive.com/haskell-cafe@haskell.org/msg37765.html

2008/11/26 Andrew Coppin <andrewcoppin at btinternet.com>:
> Here's an interesting question... Is it possible to attach finalisers to a
> value? (That is, have some Haskell code executed when the item in question
> is reclaimed by the GC.) I'm interested in knowing whether a particular data
> structure is shared (i.e., whether it's safe to mutate it or whether it must
> be copied first), and a simple reference-counting scheme looks like the
> easiest option.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Push the envelope.  Watch it bend.


More information about the Haskell-Cafe mailing list