DIP1000: The return of 'Extend Return Scope Semantics'

Dennis dkorpel at gmail.com
Tue Jun 15 13:57:45 UTC 2021


On Saturday, 12 June 2021 at 23:21:02 UTC, Walter Bright wrote:
> Consider:
>
>    a = b;
>
> Naturally, it moves right to left. We already have a word for 
> that in the library, "emplace".

`emplace` is currently used to construct an object on top of 
uninitialized memory. I don't think adding an overload to 
`emplace` that acts as move is going to work; even if it doesn't 
give overload conflicts, it will become difficult to determine 
whether `emplace(x, y)` is a move that destructs x or emplacement 
that initializes x with y.

Also not that currently `moveEmplace` exists, and it has the same 
(source, target) parameter order as move.

How about defining `moveTo(source, target)` and `moveFrom(target, 
source)` with an `alias move = moveTo` for backwards 
compatibility?


More information about the Digitalmars-d mailing list