Copy Constructor DIP
Johannes Pfau
nospam at example.com
Thu Jul 12 17:32:06 UTC 2018
Am Thu, 12 Jul 2018 09:48:37 -0400 schrieb Andrei Alexandrescu:
>> 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.
We have this(this) for postblits so how about this(ref this a) for copy
constructors?
Unfortunately this is currently valid code and compiles: this is treated
as typeof(this). However, we have already deprecated that, so maybe we
can reuse the syntax? It should be a quite consistent evolution from
this(this).
(Another option is this(ref this A a) which does not conflict with
existing syntax).
--
Johannes
More information about the Digitalmars-d
mailing list