Let's not make invariants const
bearophile
bearophileHUGS at lycos.com
Fri Aug 3 13:40:02 PDT 2012
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
More information about the Digitalmars-d
mailing list