<div dir="ltr">On 10 May 2013 09:09, Timon Gehr <span dir="ltr"><<a href="mailto:timon.gehr@gmx.ch" target="_blank">timon.gehr@gmx.ch</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On 05/10/2013 12:42 AM, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
On 10 May 2013 08:09, Jonathan M Davis <<a href="mailto:jmdavisProg@gmx.com" target="_blank">jmdavisProg@gmx.com</a><br></div>
<mailto:<a href="mailto:jmdavisProg@gmx.com" target="_blank">jmdavisProg@gmx.com</a>>> wrote:<br>
...<div class="im"><br>
So, using scope ref to<br>
solve that problem makes no sense, and the changes that we've<br>
proposed to make<br>
to ref to make it @safe pretty much make scope unnecessary.<br>
<br>
<br></div><div class="im">
I agree, that's why I'm also happy with 'ref' alone, but I still feel it<br>
doesn't communicate as much information, which is a trivial by contrast.<br>
<br></div><div class="im">
scope ref would be<br>
virtually identical to ref given that ref already has to guarantee<br>
that the<br>
variable being referenced doesn't get destroyed before the ref is.<br>
<br>
<br></div><div class="im">
No, there are other bonuses:<br>
- It mechanically enforces a given argument will not have a pointer<br>
taken and escape.<br>
</div></blockquote>
<br>
This is the same for 'ref' in @safe code in the final implementation.</blockquote><div><br></div><div style>Fine. @safe is expected to place more restrictions. But it's still something that people need to do sometimes in un-@safe code.</div>
<div style><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
- It gives the extra information to the programmer who can better<br>
reason about API intent.<br>
</blockquote>
<br></div>
No. scope is supposed to restrict escaping (in some way that is still to be determined). If it is overloaded to also mean 'accept rvalues', then reasoning about API intent is actually harmed, because it will not clear whether 'scope' was added to restrict escaping alone or also to accept rvalues.</blockquote>
<div><br></div><div style>The fact that it can safely receive a temporary is implicit if there is a guarantee that it will not escape.</div><div><br></div><div style>Why should explicit syntax exist to say "I accept rvalues", and not "I can safely receive temporaries"? The rvalue case is a subset, and I see no reason for it to receive special treatment.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
- It allows 'ref' alone to retain an important function where it may<br>
escape a pointer if it wants to.<br>
<br>
</blockquote>
<br></div>
In @safe code? No way.<br></blockquote><div><br></div><div style>Sure, people expect restrictions in @safe code. But it's still something that people need to do sometimes in un-@safe code.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
The only<br>
real difference would be that scope would presumably additionally<br>
prevent doing<br>
@system stuff like taking the address of the ref. I don't see how<br>
this buys us<br>
anything.<br>
<br>
<br></div><div class="im">
Yes this is an advantage, I listed it above. It buys the programmer some<br>
additional flexibility/choice.<br>
<br></div><div class="im">
I agree that auto ref isn't a great name, but it's what we already<br>
have, and<br>
using it on non-templated functions would be using it for exactly<br>
what it was<br>
designed for in the first place and how it's described in TDPL.<br>
<br>
<br></div><div class="im">
I'm not going to change my position that it makes no sense, and is<br>
misleading/confusing without some real arguments, which nobody seems<br>
able to provide.<br>
auto ref has already shown to create misunderstanding in the minds of<br>
non-super-technical programmers.<br>
</div></blockquote>
<br>
I think that this should be an oxymoron.</blockquote><div><br></div><div style>What?</div><div style><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Syntax should encourage correct understanding.<br>
<br>
</blockquote>
<br></div>
It can't. FWIW overloading scope fails this requirement badly.<br></blockquote><div><br></div><div style>It's not an overload, it's a natural extension of the concept.</div><div style>Using auto is an overload!</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">
As has already been discussed in this thread, it will introduce<br>
maintenance<br>
problems if ref accepts rvalues.<br>
<br>
<br></div><div class="im">
I'm not bothered by that personally, but if it's critically important,<br>
then we start arguing scope ref again. Otherwise I am happy to accept<br>
'ref' with new added safety.<br>
</div></blockquote>
<br>
Either scope ref will turn out to be liable to similar issues, or a keyword will have been wasted.<br></blockquote><div><br></div><div style>I don't understand? Can you expand this comment?</div></div></div></div>