Reference counted containers prototype

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Dec 26 18:47:50 PST 2011


On 12/26/11 11:25 AM, Andrei Alexandrescu wrote:
[snip]
> Destroy.

Walter indeed just destroyed me over the phone: I conflated reference 
counting with copy-on-write. Essentially instead of defining a reference 
type that's garbage-collected, I defined a value type that has cow.

Which is not bad! Check out the quick fix at http://pastebin.com/HHw06qrc.

With that, cow is a sheer policy. With the magic of opDispatch it looks 
like we can define reference counted containers _and_ value containers - 
all in very little code.

The perspectives here are extremely exciting. The question remains how 
to best package this awesome array of options to maximize coherence. So 
we have:

1. "Basic" containers - reference semantics, using classic garbage 
collection

2. Reference counted containers - still reference semantics, using 
reference counting

3. COW containers - value semantics, using reference counting to make 
copying O(1).

How to we provide an Apple-style nice wrapping to all of the above?


Andrei




More information about the Digitalmars-d mailing list