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

tsbockman thomas.bockman at gmail.com
Thu Mar 11 01:27:00 UTC 2021


On Thursday, 11 March 2021 at 00:31:01 UTC, deadalnix wrote:
> On Wednesday, 10 March 2021 at 22:51:58 UTC, tsbockman wrote:
>> Am I the only one who thinks that it would be better to have 
>> syntax that accurately reflects the semantics, instead of just 
>> documenting "this syntax is a lie"?
>
> No, I think there is a problem with using opAssign here, 
> because "this" will refers to something that is possibly 
> uninitialized, and the old value may not be consumed fully.
>
> Due to problem #1, this kinda need to be a constructor rather 
> than an opAssign.

Yeah, studying the DIP I can't figure out what problem the move 
`opAssign` is supposed to solve that the constructor doesn't:
     
https://forum.dlang.org/post/kzgybicwqwlfyiiefucc@forum.dlang.org

> Due to problem #2, this kinda need not to take another struct 
> as argument.

I think forbidding the move constructor from explicitly accessing 
the source at all is overly restrictive for a systems programming 
language. Full access should still be available, even if it can't 
be compiler-verified @safe.

> Which leave me with the one conclusion: the postblit needs to 
> be recycled into a move constructor.

Since the `this(this)` syntax of the postblit is unique, that 
would be a valid solution to my concern about misleading syntax.


More information about the Digitalmars-d mailing list