On 2/5/13 2:44 PM, Zach the Mystic wrote:
On Tuesday, 5 February 2013 at 18:33:36 UTC, Andrei Alexandrescu wrote:
I have a DIP in the making that makes "ref" entirely sealed, i.e. it
makes it impossible to have a dangling ref in safe code. If that DIP
gets approved, then DIP23 gets considerably simplified because
operator& won't be applicable to the result of a function anymore.


Andrei

I hope it at least considers my proposal with regard to 'out' return
values. 'out' implies ref and guarantees that the result is as good as
global:

out int foo(ref int a) { return a; } // Error, 'out' return may not
return ref parameter
out int goo(ref int a) { return new int; } // Fine

My impression was that this would solve 98% of problems, the other 2%
requiring scope parameters, which also imply ref:

ref int haa(ref int a, scope int b) { return b; } // Error, may not
return scope parameter
ref int gaa(ref int a, scope int b) { return a; } // Fine

I'm sorry, I didn't know of that proposal. Generally we're aiming for economy of means i.e. we want to clarify semantics of existing syntax instead of adding new syntax and semantics.

Andrei

Reply via email to