Copy Constructor DIP and implementation

Elie Morisse syniurge at gmail.com
Wed Sep 12 16:04:57 UTC 2018


On Wednesday, 12 September 2018 at 11:39:21 UTC, Dejan Lekic 
wrote:
> On Tuesday, 11 September 2018 at 15:22:55 UTC, rikki cattermole 
> wrote:
>>
>> Here is a question (that I don't think has been asked) why not 
>> @copy?
>>
>> @copy this(ref Foo other) { }
>>
>> It can be read as copy constructor, which would be excellent 
>> for helping people learn what it is doing (spec lookup).
>>
>> Also can we really not come up with an alternative bit of code 
>> than the tupleof to copying wholesale? E.g. super(other);
>
> I could not agree more. @implicit can mean many things, while 
> @copy is much more specific... For what is worth I vote for 
> @copy ! :)

@implicit makes sense if extending explicitly implicit calls to 
all other constructors gets somday considered. Some people argued 
for it and I agree with them that it'd be nice to have, for ex. 
to make a custom string struct type usable without having to 
smear the code with constructor calls.


More information about the Digitalmars-d-announce mailing list