From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-01-01 22:46:38
Dan W. wrote:
>Reece Dunn wrote:
>>Has there been any discussion regarding an invariants library (advanced
>>assert), or is there one already implemented in boost?
>The compiler I'm using, Digital Mars version 8.38 already supports
>invariant, pre- and post-conditions. See...
cool! But these seem to work via assert which will terminate the program
upon invariant failure.
With C++ having exception support, surely the exception mechanism is a
better way to deal with invariants that do not hold? This allows the client
code to react to the failure and report something readible to the user,
invariant failure: cannot access a null pointer, in ...
instead of something like:
abnormal program termination
Also, you need a compiler that supports the DBC extensions. The current
thinking behind the new C++ standard is to adopt a minimal set of language
extensions and a large number of library extensions (c.f. Bjarne Stroustrup,
et. al.). Having a library-based invariant mechanism (integrating into the
exception handling mechanism) allows support for older compilers (GCC
2.95.x; VC6; etc) that do not implement C++0x features.
>and I also just saw a couple of boost invariant implementations while
>browsing through the files section,
I could only find http://groups.yahoo.com/group/boost/files/DbC which
appears to support assert, not throw. Also, the files are old (2001).
>Design By Contract is such a wonderful concept, BTW, I used to program in
>Eiffel, and there's nothing I miss more than its built-in DBC.
I agree, DBC is a powerful concept. What I am trying to do is open up the
discussion on how it should be implemented in C++.
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk