[Haskell-cafe] idea for avoiding temporaries

David Roundy droundy at darcs.net
Thu Mar 8 14:58:35 EST 2007


On Thu, Mar 08, 2007 at 02:50:51PM -0500, Brandon S. Allbery KF8NH wrote:
> On Mar 8, 2007, at 14:21 , David Roundy wrote:
> >I'm thinking you're missing the point.  The point is to copy without
> >writing, and that requires some knowledge (whether static or  
> >runtime) of
> >whether anyone else has a reference to my data--which copy-on-write  
> >won't
> >give me.
> 
> Actually, I was thinking this sounded a lot like DiffArrays.  You  
> don't actually get a guarantee that anything else isn't holding a  
> reference, but you do get destructive update with any old references  
> being quietly changed to diffs against the head.

Except that DiffArrays are slow and expensive in both space and time
(compared with strict unboxed arrays).  They necesarily hold boxed values
so you pay a factor of at least two in space cost (for arrays of Doubles)
right off the top, and there's no way you could recover that.  I'll admit
that they could be useful for something, but I couldn't guess what.  In my
experience, arrays are always used with strict values, and updates change
all the values in an array.
-- 
David Roundy
Department of Physics
Oregon State University


More information about the Haskell-Cafe mailing list