Discussion: Rvalue refs and a Move construtor for D

Manu turkeyman at gmail.com
Thu Sep 5 22:28:44 UTC 2019

On Thu, Sep 5, 2019 at 2:55 PM kinke via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Thursday, 5 September 2019 at 21:31:59 UTC, Manu wrote:
> > We lose by-val calling semantics, which are more efficient for
> > small
> > struct's (most things), and certain classes of wide-registers in
> > various architectures (impossible to codify the proper rules in
> > the
> > language).
> No, I've explicitly stated that this obviously only affects
> non-PODs and large PODs. On Win64, `large` is already anything >
> 8 bytes. Of course we don't want to pass an int by ref.

You dismissed the second half of my sentence.

> > You talk about C++ rval references as if they're complex, but
> > they're
> > really not.
> For people with C++ background they probably aren't. I doubt
> it'll increase the interest in D from Java/C#/JavaScript people.

You don't need to use this. `this(T byVal)` is a valid move
constructor if you don't care for the complexity.
But in the event you DO want or need this, then it should be
comprehensive, not compromised.

> [And a great design IMO doesn't include `T&&` meaning different
> things for a templated function and a regular function, but
> that's off-topic.]

We have `auto ref`, and I expect that would express that case in a
more clear way.

More information about the Digitalmars-d mailing list