Move Constructor Syntax
RazvanN
razvan.nitu1305 at gmail.com
Wed Oct 16 09:34:57 UTC 2024
On Tuesday, 15 October 2024 at 16:54:50 UTC, Manu wrote:
> Okay, but I've asked people to stop talking about move
> constructors... it seems to have poisoned everyone's brains
> with irrelevant focus. We're talking about function arguments
> in general, we don't need more bizarre edge cases, especially
> not so deep in the foundations.
>
> Run your thought experiment with:
> void f(T);
> void f(ref T)
>
> The constructor isn't special... don't special-case the
> constructor.
>
I think that Timon did an excellent job at explaining why we are
focusing on constructors. Also, as he noted, those are
implementation details - modifying
the code to fix the current infinite recursion depends largely on
how we treat
overload resolution with respect to copy/move constructors. I
tried to express
the same idea, but Timon did it better. So, from my perspective,
which is an
implementation perspective, it's a matter if we are willing to
special case the
move/copy constructor base case in the overload resolution
mechanism or not.
> "Trade offs"? Do you have anything in mind?
> I would be surprised if there are any 'trade-offs'; any change
> here will
> probably be fixing language holes or broken edge cases... what
> actually
> stands to break? What good-stuff™ could we possibly be
> 'trading' away?
I was talking about implementation trade-offs, not user facing
trade-offs.
I.E. we are modifying the overload resolution algorithm by adding
a special (or base) case. It could be that this is desirable in
this case, I do not know, but
I suspect that this is the reason why Walter is on the "let's add
new syntax for this" wagon (but I might be wrong).
As for the `this(typeof(this))` being a move constructor - I
completely agree with everything you've said this far. I am not
counter-arguing anything that you said, I'm just presenting what
the situation with respect to the compiler implementation is.
RazvanN
More information about the Digitalmars-d
mailing list