Let's not make invariants const

Davidson Corry davidsoncorry at comcast.net
Sat Aug 4 23:22:12 PDT 2012


On 8/3/2012 1:48 PM, Alex Rønne Petersen wrote:
> The problem here is that making invariants const *now* means that using
> them in conjunction with Phobos code becomes next to impossible. Casting
> away const will become common practice, and that ain't exactly the way
> we want to go. :/

Understood and agreed. Casting away const just to get the thing to 
compile, rather than correcting the code that throws the 
const-downcheck, is wasted effort (or worse, since it hides the problem.)

Perhaps make the invariant const-downcheck a compiler warning, with the 
understanding that it will become a compiler *error* in some future 
release? Kind of like an automatic "deprecated" for invariants re this 
issue?




More information about the Digitalmars-d mailing list