DIP 36: Rvalue References

kenji hara k.hara.pg at gmail.com
Thu Apr 11 02:26:50 PDT 2013


2013/4/11 Dicebot <m.strashun at gmail.com>

> You don't think exposing creation of temporaries is low level
> implementation
> detail?
>

No. In this case, it is the purpose of 'scope ref', not is the
implementation details.

What is the language semantics and what is the implementation detail - that
varies depending on what is properly supported in the language. D
explicitly distinguishes lvalues and rvalues, and also defines that rvalue
cannot be taken its address (== reference).

The purpose of 'scope ref' is that the parameter can be received both
lvalues and rvalues with one function body. To receive lvalues, scope ref
should take the address of them. As a conclusion, to receive rvalues
temporary creation is necessary in caller site.

Yes, it mostly represents implementation details, but it is still
description of language semantics.
This confusion is almost inevitable. Because the essential purpose of
'scope ref' is already "efficiency".

Furthermore, note that the desired "efficiency" is not "the speed of
argument passing".
I recognize that it is "to avoid code bloating of function body". If you
need "most efficient argument passing", you should choose it from the
argument type. 'scope ref' is not a thing to make the choice automatic.

Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130411/ff27256c/attachment.html>


More information about the Digitalmars-d mailing list