Transitive const sucks
James Dennett
jdennett at acm.org
Thu Sep 13 19:49:25 PDT 2007
Walter Bright wrote:
> James Dennett wrote:
>> Walter Bright wrote:
>>> You cannot paste const on at the top level,
>>> it has to be put in at every level underneath it.
>>
>> I'm not sure what you mean by that. There's not much
>> context in which to interpret it.
>
>
> Try turning a char* into a const char* at the top level of your program
> where you don't use const anywhere else. You'll have to add it to every
> function that takes that variable as an argument, then recursively add
> it to every function that one calls.
OK, now I understand: and what you say is true, const-correctness
can't trivially be layered on top of const-ignorant ccode unless
you tolerate a boundary layer with const_cast where needed. That's
a good thing and a bad thing -- good in that it puts pressure on
the lower layers to "do the right thing", bad in that it makes it
harder for higher layers to do so if the layers beneath do not.
However: for most C++, 99% of the time, it's not a problem.
-- James
More information about the Digitalmars-d
mailing list