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

Walter Bright newshound2 at digitalmars.com
Tue Mar 16 08:22:07 UTC 2021


On 3/15/2021 1:09 PM, tsbockman wrote:
> I was trying to figure out what your original, general-purpose move *assignment* 
> algorithm could be. That's what my code example is for.

The answer is, it depends on how the programmer set up the contents of the 
object, in particular, how the ownership works. It's up to the programmer to 
make it work so the user of the type sees the semantics as described.

For example, if it's pointing to unique objects, then the destructor for the 
destination is called first. If it's pointing to ref counted objects, then the 
destructor is called last.

The language doesn't specify that. The programmer does, and the programmer needs 
to make it work. Hence the "as if" rule.


More information about the Digitalmars-d mailing list