Boost logo

Boost :

From: Martin Bosticky (mbosticky_at_[hidden])
Date: 2002-10-31 04:27:29


> Why is the class necessary in your example? For pre-conditions and
> post-conditions, why does DBC require much beyond assertions? Admittedly,
> Eiffel pre-conditions and post-conditions can get quite complex, and I
think
> it's good to support that in C++. Most of my functions don't need much
> beyond simple assertion mechanics. For those that do, you can always
write
> a private const member function to ensure that you are not modifying what
> you are testing. In the case of free functions, you could package up the
> data into a tuple of const items and pass that to pre- & post-condition
> checking functions. Am I missing something?

I wanted to deal with exceptions. ie when exceptions are thrown, i wanted to
execute code to test for invariants conditions. This is because exceptions
could be cought later as part of normal programming flow but the object
invariants could have been broken.

The other reason is that if there is more than one "return" from the body of
the function [run()] then this is always handled correctly. ie. next
programmer after you managing the code can not awoid the postconditions
checking easily by putting extra return somewhere in the middle of the body.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk