DIP 1018--The Copy Constructor--Formal Review

Andrei Alexandrescu SeeWebsiteForEmail at erdani.com
Mon Feb 25 16:31:22 UTC 2019


On 2/24/19 4:02 PM, Manu wrote:
> On Sun, Feb 24, 2019 at 2:50 AM Mike Parker via Digitalmars-d-announce
> <digitalmars-d-announce at puremagic.com> wrote:
>>
>> Walter and Andrei have requested the Final Review round be
>> dropped for DIP 1018, "The Copy Constructor", and have given it
>> their formal approval. They consider copy constructors a critical
>> feature for the language.
>>
>> Walter provided feedback on Razvan's implementation. When it
>> reached a state with which he was satisfied, he gave the green
>> light for acceptance.
>>
>> The DIP:
>> https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1018.md
>>
>>
>> The implementation:
>> https://github.com/dlang/dmd/pull/8688
> 
> I mean like, my DIP was almost violently rejected, but in here there's
> text like this:
> 
> "The parameter of the copy constructor is passed by a mutable
> reference to the source object. This means that a call to the copy
> constructor may legally modify the source object:"
> 
> I can't see how that could be seen in any way other than what might
> reasonably be described as "a hole large enough to drive a truck
> through"...

Thanks for the observation. We do not think this creates a hole in the
language. Indeed there is risk for misuse but we thought it's better to 
pass the "true" source of the copy to the constructor instead of 
affixing additional qualifiers to it. There are important simplicity 
benefits to doing so because "const" is ambiguous in D as it could 
originate either from mutable or immutable data. Furthermore, the risk 
is encapsulated in the type's implementation and not as a 
misunderstanding between the caller and the callee.

I'll add that pointing out a DIP's weaknesses in order to claim an 
injustice in another DIP is a understandable, but not productive. The 
proposers (Razvan and myself) and Walter (the reviewer) do not know how 
to make DIP 1018 better. Walter and I do know, and we have shared, how 
to make DIP 1016 better.


Andrei


More information about the Digitalmars-d-announce mailing list