Copy Constructor DIP

Andrei Alexandrescu SeeWebsiteForEmail at erdani.com
Mon Jul 16 19:06:07 UTC 2018


On 7/14/18 11:26 AM, Jacob Carlborg wrote:
> On Friday, 13 July 2018 at 01:18:48 UTC, Andrei Alexandrescu wrote:
>> On 7/12/18 2:30 PM, ag0aep6g wrote:
> 
>>> You're still potentially changing the semantics of existing code. 
>>> `@implicit` can be a UDA today:
>>>
>>> ----
>>> enum implicit = 0;
>>> struct C
>>> {
>>>      @implicit this(ref C another) {}
>>> }
>>> ----
>>>
>>> Today, that's a normal constructor. With the DIP, it becomes a copy 
>>> constructor.
>>
>> That is correct and a liability of the current DIP. That should be 
>> mentioned in it.
> 
> That's easily fixed by implementing a compiler recognized UDA. That 
> would mean that it would only be a copy constructor if "implicit" is 
> defined in core.attribute. This would also avoid any special syntax in 
> the parser. The already existing @selector is implemented like this.

Affirmative. We're going that route, similar to "@safe" and "@nogc".



More information about the Digitalmars-d mailing list