[Haskell-cafe] idea for avoiding temporaries

Dan Weston westondan at imageworks.com
Thu Mar 8 16:31:19 EST 2007


I might be missing the point, but I think you are missing mine.

The copy-on-write I am talking about means that it's no longer "your 
data", so you don't need any knowledge of who has access to it because 
you don't own it or have a pointer to it. It is owned by some broker 
from which you request a read-only or write access handle as needed. 
Requested changes to underlying data already shared by others triggers a 
copy and reassignment of pointers to it for your handle alone.

The copy cost appears only when there is more than one handle to the 
same data and one of them changes it.

All this can be wrapped up and hidden away. If you want to escape this 
broker business and steal back your data, just ask: the broker will 
duplicate shared data needed by others, change their pointers to it, 
then disown the pointer it returns to you.

This is copying without writing (unnecessarily). Or am I missing something?

Dan

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.
> 
> David
> 
> On Thu, Mar 08, 2007 at 11:15:25AM -0800, Dan Weston wrote:
>> Or possibly more generally copy-on-write, which requires one more level 
>> of indirection (handle instead of ptr). Since you are talking about 
>> using ForeignPtr, this is already within your power to prototype, I 
>> should think.
>>
>> Dan
>>
>> Dan Piponi wrote:
>>> On 3/8/07, David Roundy <droundy at darcs.net> wrote:
>>>
>>>> I started wondering whether there's a solution that would allow us to
>>>> write pretty high-level pure functional code, while the RTS can realize
>>>> at run-time that we have the only reference to the input argument and
>>>> that it is therefore safe to consume it destructively.
>>> I think you're talking about uniqueness typing which is supported by
>>> the programming language Clean.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 




More information about the Haskell-Cafe mailing list