12-Dec-2014 00:41, Walter Bright пишет:
On 12/11/2014 4:47 AM, Manu via Digitalmars-d wrote:
On 8 December 2014 at 07:29, Walter Bright via Digitalmars-d
<[email protected]> wrote:
I don't have the perfect proposal, but I feel very strongly about 2
things:
1. It must not be a storage class; the concept was a disaster with
ref, and I struggle with this more frequently than any other 'feature'
in D.
I simply do not understand why distinguishing beteen ref and not-ref is
a cornerstone of everything you do.
I would hazard a guess that const T& is something lots of C++ got
addicted to as the most common way of parameter passing. There is
nothing exactly like that in D, auto ref was quite close but only for
templates and it instantiates 2 distinct bodies for ref and non-ref at
the moment.
It allows easy pass by ref for both r-values and l-values with logical
const and is likely what Manu is referring(!) to.
Truth be told it's not always the fastest way, in fact Boost C++ has
template for optimal parameter passing - call_traits<T>::param_type but
it must be too cumbersome for actual use as I never seen it used in the
wild.
http://www.boost.org/doc/libs/1_57_0/libs/utility/call_traits.htm
--
Dmitry Olshansky