Could const/invariant be optional?

Janice Caron caron800 at googlemail.com
Fri Mar 28 12:53:13 PDT 2008


On 28/03/2008, Craig Black <cblack at ara.com> wrote:
> 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.

I don't see how that would work. If I wrote

    void f(C c)
    {
        /*code*/
    }

    void f(const(C) c)
    {
        /*different code*/
    }

and you "disabled const", wouldn't that make the above code a compile
error (function defined twice)?



More information about the Digitalmars-d mailing list