const(Object)ref is here!

Michel Fortin michel.fortin at michelf.com
Tue Dec 7 04:11:58 PST 2010


On 2010-12-07 05:23:34 -0500, "Simen kjaeraas" <simen.kjaras at gmail.com> said:

> 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?

Yes.


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

Great. That's how it works. I'm glad to see it suits you.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list