http://wiki.dlang.org/DIP25
Manu via Digitalmars-d
digitalmars-d at puremagic.com
Tue Dec 30 22:12:54 PST 2014
On 31 December 2014 at 15:28, Andrei Alexandrescu via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On 12/30/14 7:32 PM, Manu via Digitalmars-d wrote:
>>
>> While that code is legal, the rejection of rvalue->ref is absolutely
>> arbitrary.
>> The 'workaround' for not allowing rvalue->ref is to simply assign it
>> to a stack local with a stupid name (eg: t1, t2, etc) on the preceding
>> line.
>> That workaround appears in*every* instance that rvalue->ref would be
>> used, making code messy and more difficult to maintain.
>
>
> The alternate hypothesis is "ref" is being misused. "ref" is for propagating
> changes into the arguments. It should be rare that code does not actually
> care for that. Unlike in C++, ref is seldom needed for optimizing copies
> away. -- Andrei
Exactly like C++, ref it equally needed for optimising copies away. If
you use separate compilation, or binary libs (normal practise outside
OSS), then you still need it.
Also, when binding to external code; C++ api's have ref, so D bindings
have ref. I interact with C code more than I interact with other D
code.
Your view on ref only stands true in an 'everything is D' world, which
we are clearly not in, and I don't see any risk of that happening any
time soon. I'm suspect it may never happen.
More information about the Digitalmars-d
mailing list