<div dir="ltr">Temporaries which created on stack to pass an address to `scope ref` parameter would be destroyed after the "current statement/expression".<div><br></div><div>T rvalue();</div><div><br></div><div>void foo(scope ref T) { ... }</div>
<div>foo(rvalue());   // here is "current statement/expression"</div><div>// lowered to: { auto __tmp = rvalue(); foo(__tmp);  __tmp.~this(); };</div><div><br></div><div>Note that the lifetime of taken rvalue is mostly same as non-ref parameter case.</div>
<div>void bar(T arg) { ... arg.~this(); }</div><div>bar(rvalue());</div><div>// the rvalue argument is moved into the function 'bar', and destroyed inside function.</div><div><br></div><div>Kenji Hara</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2013/4/24 Diggory <span dir="ltr"><<a href="mailto:diggsey@googlemail.com" target="_blank">diggsey@googlemail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wednesday, 24 April 2013 at 00:54:12 UTC, kenji hara wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
2013/4/24 Manu <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc 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 class="im">
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.<br>
</blockquote></div><br></div>