Const sucks

Nathan Reed nathaniel.reed at gmail.com
Mon Sep 10 12:55:24 PDT 2007


Janice Caron wrote:
> Oh wait! I do have one comment, or question, or whatever.
> 
>> const int* p = &x;  // neither p nor *p can be changed
>> const(int*) p = &x;  // neither p nor *p can be changed
> 
> Two ways of writing the same thing. I don't understand the need for
> the bracketless version. Could we not just insist that the brackets
> must always be there? Or does the lack of brackets actually mean
> something? (if it does, it's back to being confusing again).

I'd rather have the bracketless version to save typing in the case when 
I want to have the whole thing be const (which is the most common case, 
I believe).

Thanks,
Nathan Reed



More information about the Digitalmars-d mailing list