DIP74: Reference Counted Class Objects
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 28 19:43:26 PST 2015
On 2/28/15 7:30 PM, Manu via Digitalmars-d wrote:
> On 1 March 2015 at 13:13, Andrei Alexandrescu via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>> Inserting calls to opAddRef and opRelease, and the rules that allow their
>> elision, follow quite closely (albeit not 100% identically) the rules for
>> inserting calls to copy constructors and destructors.
>
> The most important case to be elided is the function call case.
> Passing struct to function results in postblit and destructor for
> every call.
> If postblit and destructor were sufficient, we would have been
> satisfied with RC in D for years.
RefCounted has been in there for quite a while and worked with structs.
Its main problem was it wasn't safe. With DIP25 safety of structs
(including those that use reference counting for their payload) becomes
a reality.
>>> Okay, so if I'm not better off then I've always been, what is the good
>>> of DIP74 to me?
>>
>>
>> The title reads "Reference Counted Class Objects".
>
> That title is not immutable.
> If DIP74 is a starting point, and you can see extension to the struct
> case in the future, then I'll let this go now.
It would be mightily confusing to add opAddRef and opRelease calls for
structs that follow the constructors/destructors ever so closely. It
might be more productive to look into improvements of optimizations
related to copying objects.
Andrei
More information about the Digitalmars-d
mailing list