Head Const

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 18 15:00:36 PST 2016


On Thursday, 18 February 2016 at 22:48:01 UTC, Walter Bright 
wrote:
> struct A { int* pi; }
>
> and *pi will be mutable even though pi is __const.

Here's the big deal: when you have started on an implementation 
with constness in, and then evolve the codebase and have to turn 
some fields mutable or face a major rewrite, guess what you will 
do?

You will look for ways to save time and cast away constness, 
write some comment that it probably should be fixed later, but if 
it looks like it is working it will never be fixed...

So you effectively cannot avoid "mutable". You can claim they 
shouldn't do it, but you cannot enforce it.



More information about the Digitalmars-d mailing list