Escaping the Tyranny of the GC: std.rcstring, first blood
Dmitry Olshansky via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 26 14:50:25 PDT 2014
24-Sep-2014 18:55, Andrei Alexandrescu пишет:
> 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.
Read that as
struct RefCounted(T){
void opInc();
void opDec();
}
The main thing is to let compiler know the stuff is ref-counted in some
generic way.
>
> 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
>
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list