Let's not make invariants const

Paulo Pinto pjmlp at progtools.org
Fri Aug 3 13:14:31 PDT 2012


On Friday, 3 August 2012 at 19:43:18 UTC, Simen Kjaeraas wrote:
> On Fri, 03 Aug 2012 21:36:41 +0200, H. S. Teoh 
> <hsteoh at quickfur.ath.cx> wrote:
>
>> IMO, if you need to be changing stuff inside invariants, then 
>> you're
>> using it wrong. Invariants are intended to verify program 
>> logic, not to
>> do things like altering object state. The point is to be able 
>> to compile
>> with invariant code turned off, and still have the program 
>> work exactly
>> as before.
>
> True. Then add in a (standard) library that's not 
> const-correct, and you
> have invariants that are outright unusable.

Personally I feel D's contracts are still a bit off of what 
Eiffel, .NET and Ada 2012 offer.

--
Paulo


More information about the Digitalmars-d mailing list