Hi,

Am Samstag, den 03.11.2012, 11:26 +0100 schrieb Peter Divianszky:
> > This can be implemented by replacing every record update
> >
> >     r' = r { x = y }
> >
> > with
> >
> >     r' = r { x = unsafePerformIO (cond-update r r' (x r) y) }
> >
> > where we keep the current record update mechanism and implement
> > cond-update like
> >
>
> cond-update :: r -> r -> x -> IO x
> cond-update r_old r_new x_old x_new = do
>       eval x_new
>       b <- x_old === x_new
>       when b (replace r_new r_old)
>       return x_new
> 
> > where (===) is pointer-equality and replace is a low-level function
> > which replaces thunks in the heap.

I think one problem with this approach is that now, until "x r'" is
evaluated, you keep both r and r' alive. If r was _not_ retained by
anything else, then you are now preventing the GC from freeing it and
hence increasing the memory footprint.

Greetings,
Joachim


-- 
Joachim "nomeata" Breitner
  m...@joachim-breitner.de  |  nome...@debian.org  |  GPG: 0x4743206C
  xmpp: nome...@joachim-breitner.de | http://www.joachim-breitner.de/

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to