DIP23 draft: Fixing properties redux

Zach the Mystic reachBUTMINUSTHISzach at gOOGLYmail.com
Tue Feb 5 11:44:11 PST 2013


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


More information about the Digitalmars-d mailing list