The tailconst problem (and suggestions for solution)

Craig Black cblack at ara.com
Fri Dec 7 07:42:21 PST 2007


"Janice Caron" <caron800 at googlemail.com> wrote in message 
news:mailman.250.1197041224.2338.digitalmars-d at puremagic.com...
> On Dec 7, 2007 3:12 PM, Craig Black <cblack at ara.com> wrote:
>> What I don't understand is
>> why.
>>
>> const(C) c;
>>
>> Means that the reference is constant.
>
> Look at it another way. You'd want
>
>    const T t;
>    t = something;
>
> to fail, always - regardless of the type of T. It has to be true when
> T is a class, because it has to be true for everything.
>
> Remember, the two new (vastly simplified, but brilliant) rules are:
> (1) const type identifer; means the same thing as const(type) identifier;
> (2) Everything inside the brackets is const

I think you are misunderstanding my question.

Everything inside the parenthesis should be constant.  I am in total 
agreement here.  But in this example, the only thing that appears inside the 
parenthesis is the class type, and it is interpreted as the class instance 
is mutable, but the reference is constant.

I've been reading the other const thread and Sean Kelly mentioned the same 
thing regarding arrays.  I think Walter mentioned fixing this in the next 
release.  I'm not sure though. 





More information about the Digitalmars-d mailing list