Escaping the Tyranny of the GC: std.rcstring, first blood

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 24 07:55:13 PDT 2014


On 9/24/14, 3:31 AM, Dmitry Olshansky wrote:
> 23-Sep-2014 19:13, Andrei Alexandrescu пишет:
>> On 9/23/14, 12:17 AM, Dmitry Olshansky wrote:
>>> In my imagination it would be along the lines of
>>> @ARC
>>> struct MyCountedStuff{ void opInc(); void opDec(); }
>>
>> So that would be a pointer type or a value type? Is there copy on write
>> somewhere? -- Andrei
>
> It would be an intrusively counted type with pointer somewhere in the
> body. To put it simply MyCountedStuff is a kind of smart pointer.

Then that would be confusing seeing as structs are value types. What 
you're saying is that a struct with opInc() and opDec() has pointer 
semantics whereas one with not has value semantics. That design isn't 
going to fly.

For classes such a design makes sense as long as the class is no longer 
convertible to Object. That's what I'm proposing for RCObject (and 
Throwable that would inherit it).


Andrei



More information about the Digitalmars-d mailing list