Rvalue references - The resolution

Walter Bright newshound2 at digitalmars.com
Sat May 4 17:27:12 PDT 2013


On 5/4/2013 4:51 PM, Timon Gehr wrote:
> What is the point? Rust conservatively assumes this by default.

We could do that, too, and then disallow all code that looks like:

       ref T foob(ref U u);

       ref T bar() { U u; return foob(u); }

which I doubt would be very popular. Or we could add "scope ref" annotations 
everywhere, which brings another set of problems as I pointed out.

I.e. there is no free lunch with this. Rust uses annotations, it doesn't have a 
clever way to not have them. The choices are:

1. use annotations
2. issue error on otherwise useful cases
3. add runtime check
4. put 'suspicious' locals on the heap, like what is done for closures

We decided that (3) was the most practical and was the easiest for users to deal 
with.


More information about the Digitalmars-d mailing list