Copy Constructor DIP and implementation

Nicholas Wilson iamthewilsonator at hotmail.com
Tue Sep 25 13:21:04 UTC 2018


On Tuesday, 25 September 2018 at 12:33:30 UTC, RazvanN wrote:
> After discussing with Walter and Andrei we have decided that we 
> are going to drop @implicit for now as it may cause bugs (as 
> Jonathan has highlighted) and consider constructors that have 
> the form this(ref $q1 S rhs) $q2 as copy constructors. I will 
> update the DIP with more information.
>
> Also, regarding the cohabitation between postblit and copy 
> constructor: in order to make the transition smoother, whenever 
> a postblit and a copy constructor are found togheter in a 
> struct, the former is used and the latter is ignored (even if 
> it is a field postblit). Once the postblit is going to be 
> deprecated we can do the opposite and use the copy constructor 
> and ignore the postblit.
>
> If @implicit is going to be introduced then that is going to be 
> a DIP on its own.

Thanks!

I still think a -dip10xx flag to control which to prefer is worth 
doing, since

a) it won't be hard to do and will make the transition smoother 
still , and

b) IIRC the motivating factor for this is memory safety. Delaying 
memory safety while waiting for a deprecation period to expire ( 
O(years) ) for code that wants to remain backwards compatible 
with older compiler versions is not something we should be 
encouraging.

In the deprecation period if no flag is given prefer postblit to 
copy if both are defined, if flag is given prefer copy over 
postblit.

Nic


More information about the Digitalmars-d-announce mailing list