DIP74: Reference Counted Class Objects

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 26 17:32:49 PST 2015


On 2/26/15 5:28 PM, Rikki Cattermole wrote:
> On 27/02/2015 10:50 a.m., Andrei Alexandrescu wrote:
>> http://wiki.dlang.org/DIP74 got to reviewable form. Please destroy and
>> discuss.
>>
>> Thanks,
>>
>> Andrei
>
> Either I missed something or:
>
> If I go new a type like:
> Widget widget = new Widget();
>
> This would still use the GC to allocate the memory + emplace it. Even if
> it contains the two special RC functions.

Yah, DIP74 is intentionally very "policy up, implementation down". It 
completely leaves the allocation mechanism to user code. See e.g. this 
excerpt: "Usually such approaches also use private constructors and 
object factories to ensure the same allocation method is used during 
creation and destruction of the object."

> Also what about properties?
> What if one of them may or may not be RC'd. Should there be a
> conditional call to the GC to add it to be scanned on assignment?

I don't understand this. Members compose naturally.


Andrei



More information about the Digitalmars-d mailing list