syntax question on "invariant" keyword

Michael Kiermaier michael.kiermaier at
Tue Jul 3 15:52:31 PDT 2007

BCS Wrote:

> This is getting into the ambiguity between an invariant function (that is 
> part of design by contract)

Thanks, I didn't know that "invariant" can also be used for functions;

> and an invariant value (that is one form of const).
> I think the way that it should be done is
> invariant(int) y;

I tried that, but:
Test.d(6): found 'int' when expecting ')'
Test.d(6): statement expected to be { }, not )
Test.d(6): found ')' instead of statement

Also, claims that "invariant int" and "invariant(int)" are NOT the same, but "invariant int" and  "final invariant(int)" are the same.

I don't know if that is true.

More information about the Digitalmars-d-learn mailing list