Discussion: Rvalue refs and a Move construtor for D

Manu turkeyman at gmail.com
Fri Sep 6 19:21:00 UTC 2019


On Fri, Sep 6, 2019 at 11:45 AM kinke via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On Friday, 6 September 2019 at 18:13:03 UTC, kinke wrote:
> > It'd just make the D ABI conform to the C++ ABI wrt. passing
> > non-PODs and large PODs by value, making the compilers adhere
> > to the D spec *and* fixing C++ interop when passing such
> > structs by value across language barriers, soomething you're
> > surely looking forward too.
> > So the proposed ABI change (pass by ref instead of on stack &
> > let callER destruct it) is the exact opposite of what you seem
> > to see it as - it's streamlining the D ABI with C++. And it's
> > orthogonal to the proposed move/forward intrinsics.
>
> Dammit, I stand corrected again, just checked the clang ABI on
> Posix x86_64 - it does pass large PODs on the stack. So please
> discard my mentionings of large PODs (those are passed by ref on
> Win64...) in this thread, my intention was always to firstly
> adopt the respective C++ ABI for each target, and secondly to
> exploit the low-level-by-ref-passing of non-PODs (AFAIK, what C++
> does for all targets) when moving lvalue arguments to by-value
> params (by eliding the temporary and passing the lvalue ref
> directly), thirdly hoping to cover enough use cases in order NOT
> to have to introduce rvalue refs in the language.

'enough' is a subjective quantity; and I respect an effort to explore
avoiding rval ref's, but also don't be xenophobic about it. It's a
really good solution, and if we don't arrive at a distinctly better
one, then I think we should accept the state of the art, and not do
something different for the sake of doing something different.
I've thought about this a lot, I personally think C++'s rval ref's
were really well thought through, and I can't imagine a simple/better
design. I also see that the only major oddity in C++ (T&&, so called,
universal references) are addressed by `auto ref`, which feels much
less surprising and more obvious for users to me.

My email way up the feed listing all the cases feels robust to me.
There's synergy with Andrei's `-preview`, and there are no changes to
existing semantics, it's purely additive.


More information about the Digitalmars-d mailing list