Could const/invariant be optional?

Craig Black craigblack2 at cox.net
Fri Mar 28 20:40:22 PDT 2008


"Janice Caron" <caron800 at googlemail.com> wrote in message 
news:mailman.247.1206734444.2351.digitalmars-d at puremagic.com...
> 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)?

No it would compile.  Const syntax would be allowed, and the ABI 
implications of const would be the same.  Only it would ignore const 
constraints. 




More information about the Digitalmars-d mailing list