ref for (const) variables

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 16 12:20:08 PDT 2015


On Monday, 16 March 2015 at 18:47:00 UTC, Namespace wrote:
>     const(Matrix)* m = &t.getCurrentModelViewMatrix(); // 
> currently
> }
> ----
>
> But IMO it would be a lot nicer if I could store the reference 
> like this:
> ----
> ref const(Matrix) m = t.getCurrentModelViewMatrix(); // nicer
> ----
>
> [Of course the name is exaggerated for the purpose of 
> demonstration.]
>
> May this be worth of an enhancement request?

Maybe, but I think you'd have to present a better argument. It's 
not obvious to me how `ref T x = y;` is supposed to be a lot 
nicer than `T* x = &y;`.

> Or was this  already rejected?

I don't know. But since it's a C++ thing, it's probably been 
discussed.


More information about the Digitalmars-d-learn mailing list