On Thu, Feb 24, 2011 at 12:57 PM, Chung-chieh Shan <ccs...@cs.rutgers.edu> wrote: > Arnaud Clère <arnaud.cl...@free.fr> wrote in article > <ik64e9$j6a$1...@dough.gmane.org> in gmane.comp.lang.haskell.cafe: >> On 24/02/2011 09:30, o...@okmij.org wrote: >> > The sort of laziness needed for non-deterministic programming calls >> > for first-class store. It can be emulated, albeit *imperfectly*, >> > for example, as was described in the ICFP09 paper. >> What do you mean by "imperfectly"? > > I think Oleg meant that, because the garbage collector only understands > the native store and not our emulation of first-class stores, cells of > a first-class store that are no longer referenced will nevertheless not > be garbage-collected until the store itself is garbage-collected. What > we need is a way to tell the garbage collector that the store reference > and the cell reference are both needed to access the data so the data > can be garbage-collected as soon as *either* the store reference *or > the cell reference* is. (Analogy from the capabilities literature: > the key and the lock are both needed to open the door so the door can > be garbage-collected as soon as either the key or the lock is.) Any > thoughts on how to achieve that? >
Here's a weak cell which is a candidate for GC as soon as either the cell or the key is lost: http://hpaste.org/44280/weak_ref_needing_both_halves The implementation is GHC specific, as far as I know. I don't know if it's exactly what you're looking for, but the idea could be adapted towards some other purpose. Antoine _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe