Let's not make invariants const
Alex Rønne Petersen
alex at lycus.org
Fri Aug 3 13:42:34 PDT 2012
On 03-08-2012 22:40, bearophile wrote:
> Alex Rønne Petersen:
>
>> So what if, for whatever reason, the invariant needs to track and
>> maintain some state in order to catch some kind of ugly bug?
>
> This is legitimate practical need. I know two or more ways to solve that
> problem, one of them is to implement the prestate (old). That's probably
> the largest hole in the D implementation of contract programming, and I
> have felt its need several times.
>
> Another solution (that doesn't replace the need for the prestate!) is
> ghost fields, that are class instance/struct fields usable only inside
> contracts and that vanish in release mode:
> http://d.puremagic.com/issues/show_bug.cgi?id=5027
>
> Bye,
> bearophile
I've used prestate in Spec#/Sing# and can definitely vouch for its
usefulness.
--
Alex Rønne Petersen
alex at lycus.org
http://lycus.org
More information about the Digitalmars-d
mailing list