<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">First of all, we should define words for the discussion.</div><div class="gmail_quote"><br></div><div class="gmail_quote">1. Let's name current `auto ref` "parameterized-ref", which works only with template functions and the `auto ref` parameter is instantiated to both ref/non-ref by the actual function argument.</div>
<div class="gmail_quote">2. Let's call it "rvalue-ref(erence)", which currently discussed, that can receive both lvalues and rvalues by one function body.</div><div class="gmail_quote"><br></div><div class="gmail_quote">
2013/4/24 Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a>></span><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im"><br></div>
The best setup would be:<br>
<br>
1. To take lvalues by reference, write "ref".<br>
<br>
2. To take lvalues and rvalues by reference, write "auto ref".<br>
<br>
Everything else is superfluous and puts the burden of justification on the proposer. With DIP36, the setup would be:<br>
<br>
1. To take lvalues by reference, write "ref".<br>
<br>
2. To take lvalues and rvalues by reference:<br>
<br>
2.1. Is it a template? Then write "auto ref".<br>
<br>
2.2. Is it a non-template? Then write "scope ref".</blockquote><div><br></div><div>The difference between 2.1 and 2.2 is not superfluous. Because:</div><div><br></div><div>1. "parameterized-ref" is already there with the syntax `auto ref`. Removing it introduces breaking language change.</div>
<div><br></div><div>2. If we remove "parameterized-ref" from D, we will lose the ability to write certain kind of template functions. For example:</div><div><br></div><div>    auto ref forward(T)(auto ref T arg) { return arg; }</div>
<div><br></div><div>The parameter `arg` is instantiated with both ref/non-ref, and forward `function` returns also both ref/non-ref value. In such case, you cannot replace "parameterized-ref" to "rvalue-ref".</div>
<div><br></div><div>These are why DIP36 is necessary. Repeatedly, I think removing current `auto ref` is not good.</div><div> </div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Currently rvalues are destroyed immediately after the call they are passed into. DIP 36 would need to change that, but fails to specify it.<br></blockquote><div><br></div><div>DIP36 does not change it.</div><div> </div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Our intent is to make "ref" always scoped and reserve non-scoped uses to pointers. We consider this good language design: we have unrestricted pointers for code that doesn't care much about safety, and we have "ref" which is almost as powerful but sacrifices a teeny bit of that power for the sake of guaranteed safety. Safety is guaranteed by making sure "ref" is always scoped (references can be passed down but never escape their bound value).<br>
</blockquote><div><br></div><div>I'm basically agreeing with the DIP25. Making `ref` more safety is possible and should.</div><div><br></div><div>I can guess that you are intended applying DIP25 to "rvalue-ref" concept. It is sane design, but DIP36 also accepts such applying DIP25. There is no issue.</div>
<div> </div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
<br></div></blockquote><span class=""><font color="#888888">
Andrei<br>
</font></span></blockquote></div><br></div><div class="gmail_extra">Kenji Hara</div></div>