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

Ben Jones fake at fake.fake
Fri Mar 5 18:35:39 UTC 2021


On Friday, 5 March 2021 at 12:19:54 UTC, Mike Parker wrote:
> This is the discussion thread for the first round of Community 
> Review of DIP 1040, "Copying, Moving, and Forwarding":
>
> https://github.com/dlang/DIPs/blob/a9c553b0dbab1c2983a801b5e89b51c5c33d5180/DIPs/DIP1040.md

I had a couple of thoughts on how to make the DIP description a 
bit more accessible (I don't think they change the mechanics at 
all).

First, I think a possible use of move constructors/move 
assignment is to support objects with internal pointers like a 
small sized optimized vector/string.  An example of what a struct 
like that would look like would be nice.

Second, it might be good to include a discussion of how structs 
are passed at the ABI level (I assume that's in the spec, but it 
would be helpful context to just highlight in the DIP).  My 
understanding is that this proposal doesn't actually change the 
function ABIs at all (for struct parameters and return values the 
caller always passes a pointer to the appropriate structs).  At 
the ABI level, for the move constructor + assignment, the `this` 
pointer and the pointer to the argument point to distinct 
structs, and the argument struct will not be used after the 
function call, correct?

To be clear, the @value attribute is only used for extern(C++) 
code where we want to force a copy, right?


More information about the Digitalmars-d mailing list