Const Ideas

Craig Black cblack at ara.com
Mon Dec 3 09:35:12 PST 2007


"Janice Caron" <caron800 at googlemail.com> wrote in message 
news:mailman.229.1196702116.2338.digitalmars-d at puremagic.com...
> On 12/3/07, Craig Black <cblack at ara.com> wrote:
>> Just to expound further, the pointer and reference syntax seems 
>> difference
>> since the reference is implicit.  Just think of  "const X x;" as "const 
>> X&
>> x;" and you will see that the same principle that applies to pointers 
>> should
>> also apply to references.
>
> Yes, I think we're on the same page here. Of course, only classes have
> references. Structs don't, ints don't, etc., but for classes, my
> preference would be for all four of the following to be exactly
> equivalent:
>
>    const C c;
>    const(C) c;
>    const C& c;
>    const(C&) c;
>
> (Which leaves open the possibility of "const(C)& c;" to mean mutable
> ref to const data").
>
> That's not the status quo, however

That syntax would looks OK, but I think it also makes sense to make 
"const(C) c" equivalent to "const(C)& c;".  Walter said that this is how the 
syntax already works.  Am I misunderstanding something?

What I don't understand is why Walter and others think that "C const c" 
violates transitivitiy.  What do they mean by transitivity?





More information about the Digitalmars-d mailing list