<div dir="ltr"><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=""><div class="h5"><div class="gmail_extra"><br>On 24 April 2013 11:02, Diggory <span dir="ltr"><<a href="mailto:diggsey@googlemail.com" target="_blank">diggsey@googlemail.com</a>></span> wrote:<br><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">On Wednesday, 24 April 2013 at 00:54:12 UTC, kenji hara wrote:<br>

<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>
2013/4/24 Manu <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>><br>
<br>
<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">
"The r-value being passed is assigned to a stack allocated temporary,<br>
which has a lifetime that is identical to any other local variable, ie, the<br>
lifetime of the function in which it appears."<br>
There, I defined it.<br>
<br>
</blockquote>
<br></div><div>
Good definition. If add more,<br>
"getting address of "scope" parameter would be disallowed, at least in<br>
@safe code, because it would be regarded as the escape of stack allocated<br>
temporary."<br>
<br>
Kenji Hara<br>
</div></blockquote>
<br>
Why does the temporary need to exist any longer than the current statement? (the current lifetime of temporaries are the statement or expression). Surely any longer is just wasting stack space.</blockquote></div></div></div>
</div></blockquote><div><br></div>scope ref a(scope ref int x) { return x; }<div>void b(scope ref int x);</div><div><br></div><div>b(a(10));</div><div><br></div><div>The temp produced from '10' needs to last longer than a(), because it can be returned to b(). Ie, the temp needs the life of any normal local declared within that scope.</div>
<div><br></div><div style>How do you describe 'wasting' stack space? Does D attempt to recycle stack space from previous short-lived locals within a single function?</div></div></div></div>