ref for (const) variables

Namespace via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 16 13:29:11 PDT 2015


On Monday, 16 March 2015 at 19:20:09 UTC, anonymous wrote:
> 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;`.
It is, for example, not nullable. ;)
>> Or was this  already rejected?
>
> I don't know. But since it's a C++ thing, it's probably been 
> discussed.
I will research this. Thank you.


More information about the Digitalmars-d-learn mailing list