Move Constructor Syntax

Manu turkeyman at gmail.com
Tue Oct 15 09:23:57 UTC 2024


On Mon, 14 Oct 2024 at 12:54, Walter Bright via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On 10/11/2024 8:44 AM, Manu wrote:
> > No that's wrong; this is EXACTLY the situation that move semantics exist
> to
> > address. Move constructor like this should ACTUALLY BE a move
> constructor!
>
> But currently this(S) is an rvalue constructor, not a move constructor.
> I've
> said this many times.
>
> Changing it would break existing code.
>

CASE STUDIES

The fact it theoretically exists doesn't make its existence useful or even
sensible.
It *might *break code; but we really need to identify whether that code IS
ALREADY BROKEN. I would give a 75% odds that any code using that pattern is
actually broken already, and I give exactly zero cares if we break already
broken code in service of correcting the single biggest gaping hole at the
heart of D.
I would also put a ~60-80% wager on any real-world instance of that pattern
*already* being some kind of move constructor, which will only benefit from
this change...
I would put maybe 90%+ odds on any given instance of this declaration being
written by a D amateur, who actually didn't understand what they were
writing, and possibly thought it does something that it doesn't actually
do; that is, I would wager with almost 100% probability, that if this
exists in the wild, it's essentially an accident. (probably a failed
attempt at a move constructor)

There is NO CONCEIVABLE USE for this pattern as it is today, outside a
weird syntactic hack with some very weird calling semantics... so; we need
case studies to consider.
We're just going to break this code, and you're just going to have to come
good with that. I will personally submit a PR to every single repo affected
by this change.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20241015/cbb07b27/attachment-0001.htm>


More information about the Digitalmars-d mailing list