A type is a set of assertions

A type offers, within the scope it defines, a set of static assertions. Within every non-static member, it offers the guarantee that the constructor has been run to completion. It takes the collaboration of the type designer to make out of this statement a strong assertion: this that the type invariant is statically guaranteed.

Of course, this guarantee may be violated by any of the member functions. The point is not so much to check whether or not this assertion holds, but to point out who is responsible for it to hold, who should be trusted.

The same is true for pre- and postconditions. They arise from types being based on blocks. They should be made explicit in the code producing them, instead of in redundant code used to dynamically test them.


Table of contents
Marc Girod
Last modified: Sat Feb 28 14:30:35 EET 1998