Copy Constructor DIP
Jacob Carlborg
doob at me.com
Sat Jul 14 15:26:33 UTC 2018
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.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list