Could const/invariant be optional?

Neil Vice psgdg at swiftdsl.com.au
Sun Mar 30 03:19:32 PDT 2008


"Craig Black" <cblack at ara.com> wrote in message 
news:fsjh4h$172o$1 at digitalmars.com...
>I think most would agree that const is more useful for some programs, but 
>more of an annoyance for others.  Could the const be disabled by a compiler 
>option?  If I disabled const when compiling a source file, I could still 
>rely on libraries that supported const, but I could write code as if there 
>were no const constraints.
>
> -Craig

I just don't see the advantage... as far as I'm aware you're never forced to 
use const and const parameters to library methods for example shouldn't be 
an issue as they should be implicitly cast without incident.

Even if you have a const object, say returned from a library method, and 
require a non-const copy of it you can simply dup, and this seems like a 
relatively rare-case.

Do you have any specific examples where const is significantly inconvenient 
and as such worth being able to disable? 





More information about the Digitalmars-d mailing list