Rvalue references - The resolution

Walter Bright newshound2 at digitalmars.com
Sat May 4 16:30:07 PDT 2013


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.


More information about the Digitalmars-d mailing list