DIP69 - Implement scope for escape proof references

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 8 15:19:25 PST 2014


On Monday, 8 December 2014 at 20:54:54 UTC, Dicebot wrote:
> But was there any reason why those traits (alien to type 
> qualifiers) were pursued? What is the problem with `ref` simply 
> meaning `non-null pointer` and allowing non-idempotent 
> ref(ref(int))?

Please no.

when you do int a; and then use a, you always either refer to a,
to memory storage (lvalue) or a, the value stored in that memory
(the rvalue).

When doing ref int a = xxx;

You specify that you don't create a new storage for a, but that
you must consider xxx as an lvalue, and bind the name a to that
same lvalue.

Once you get that, you get why ref(ref(int)) do not make any
sense, and is generally undesirable.


More information about the Digitalmars-d mailing list