Copy Constructor DIP

Luís Marques luis at luismarques.eu
Thu Jul 12 15:25:10 UTC 2018


On Thursday, 12 July 2018 at 15:14:19 UTC, Luís Marques wrote:
> More details. The DIP says:
>
> "The structName type needs to be identical to typeof(this); an 
> error is issued otherwise. This requirement may be relaxed in 
> the future in order to accomodate copying from objects of a 
> different type"
> (BTW, typo in "accomodate")
>
> That would mean that if such a relaxation were introduced, then 
> suddenly *all* copy ctors would imply implicit conversion 
> between the respective types. Given D's stance on implicit 
> conversions, I suspect that's not going to pass mustard. So I 
> would prefer the any "implicit" keyword-like annotation to be 
> reserved for explicitly approved implicit conversions.

BTW: Multiple alias this is still planned for inclusion in D, 
right? If so, what would be the (pratical?) difference between 
having copy ctors with such a relaxed type requirement and just 
defining an equivalent alias this method? In case the answer is 
that there's no significant difference, why not drop multiple 
alias this, then?


More information about the Digitalmars-d mailing list