Rvalue references - The resolution

Timon Gehr timon.gehr at gmx.ch
Sat May 4 16:51:15 PDT 2013


On 05/05/2013 01:30 AM, Walter Bright wrote:
> On 5/4/2013 3:50 PM, deadalnix wrote:
>> Require isn't the right word, or you hav to explain yourself much more.
>
> You need an explicit annotation if a ref parameter is returned by ref by
> that function. This is what Rust's annotations do.
>
> Consider:
>
>      ref T foob(ref U u) { return u.t; }
>
>      ref U bar() { U u; return foob(u); }
>
> The compiler cannot know that the ref return of foob is referring to
> local u (as opposed to, say, a ref to a global) unless it is annotated
> to say so. Rust is no different.

What is the point? Rust conservatively assumes this by default.


More information about the Digitalmars-d mailing list