Discussion Thread: DIP 1040--Copying, Moving, and Forwarding--Community Review Round 1

deadalnix deadalnix at gmail.com
Sat Mar 13 13:06:21 UTC 2021


On Saturday, 13 March 2021 at 03:12:02 UTC, Walter Bright wrote:
> On 3/12/2021 3:47 PM, tsbockman wrote:
>> ...
>
> You make a good point, that the user should define both the 
> Move Assignment and Move Constructor, or neither. Just one of 
> the pair should be an error. I agree that it would be red flag 
> if just one appeared in the code, indicative that the 
> programmer did not think it through.

The whole notion of move assignement is a hack inherited from C++ 
and don't really make sense for D.

As soon as you have 2 objects, you are out of the pure move 
scenario, and you need to deal with this fact. C++ does so by 
putting the source object in a null state and then destroying it. 
You cannot have *2* objects and then not destroy one and expect 
things to not have a ton of edge cases just like postblit for 
copy does (because you have the exact same problem in reverse 
there, you had *1* object when you wanted *2*).


More information about the Digitalmars-d mailing list