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;`.

Or was this  already rejected?

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

The last time we discussed about scope, Walter suggested allowing `ref` for local variables. He might not be opposed to extend it further to members. On the other hand, `ref` has gained different semantics with DIP25 (something like scope, more or less), so this might collide with such a change.

Anyway, the situation in D is not the same as in C++, because `ref` is not a type modifier, but a storage class.

Reply via email to