Copy Constructor DIP
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Jul 12 13:48:37 UTC 2018
On 07/12/2018 02:54 AM, RazvanN wrote:
>> What's wrong with:
>> struct S {
>> this(ref S copyFrom);
>> }
>>
>> That looks like a perfectly good copy constructor declaration ;) I'm
>> just saying, the DIP needs to explain this.
>
> That is actually a valid constructor, according to today's compiler. There
> might be code out there that uses this syntax for the constructor and
> overnight
> it will be turned into a copy constructor.
>
> I agree that the current syntax is lacking. This was Andrei's proposition
> and I was initially against it, but he said to put it in the DIP so that
> we can discuss it as a community. Maybe this syntax is better:
>
> @this(ref S a another)
>
> It looks like the c++ copy constructor but the `@` makes it different from
> a constructor, so we're good. What do you think?
We will not add syntax if we can help it.
More information about the Digitalmars-d
mailing list