const(Object)ref is here!

Simen kjaeraas simen.kjaras at gmail.com
Tue Dec 7 02:23:34 PST 2010


Michel Fortin <michel.fortin at michelf.com> wrote:

> And that's what my patch does. It only gets confusing when you add  
> modifiers:
>
> 	alias const(Object)ref A;
> 	alias const(Object ref) B;
> 	alias const(Object) C;
>
> 	A ref a;
> 	B ref b;
> 	C ref c;
>
> With my patch, variables 'a', 'b', and 'c' are all of the same type:  
> "const(Object)ref", the later 'ref' changing the constness of the  
> reference specified in the 'B' alias.

const(Object ref) is implicitly castable to const(Object) ref, no?

So to me, it seems all of these should be const(Object) ref.
Seeing Foo ref name, I read this as 'non-const reference to some
class'. IOW, if you want a rebindable reference to a class T, the type
of T should not affect what hoops you must jump through to get there.

-- 
Simen


More information about the Digitalmars-d mailing list