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

Walter Bright newshound2 at digitalmars.com
Thu Mar 18 09:55:08 UTC 2021


On 3/11/2021 1:15 AM, Arafel wrote:
> On 11/3/21 10:01, Walter Bright wrote:
>> On 3/11/2021 12:42 AM, Walter Bright wrote:
>>> Constructing from an rvalue essentially is move construction.
>>
>> I forgot to mention that the new semantics only apply to EMO objects, which 
>> require both a move constructor and a move assignment operator. The move 
>> constructor is new syntax. Therefore, it shouldn't break existing code.
> 
> But we also read in the DIP, as it has already been mentioned:
> 
>> If a Move Constructor is not defined for a struct that has a Move Assignment 
>> Operator, a default Move Constructor is defined and implemented as a move for 
>> each of its fields, in lexical order.
> 
> It's not clear if a struct would be considered an EMO if either the Move 
> Assignment Operator or the Move Constructor are defined by default.
> 
> If that's the case, any struct with an identity assignment operator would be 
> silently "upgraded" to EMO, thus potentially breaking existing code: the 
> original identity assignment might even throw, which according to the DIP will 
> no longer be allowed.

Yes, it does appear to have a conflict with `this(S)`, which wasn't part of D 
when the DIP was originally worked on. That syntax is part of the 
"-preview=rvaluerefparam" feature. Perhaps that feature can be simply replaced 
with DIP1040.


More information about the Digitalmars-d mailing list