
21 Dec
2008
21 Dec
'08
1:06 p.m.
Hi Mika,
I would prefer my word processor to announce a programming error instead of producing a core dump. Am I missing some finer point on the nature of invariants?
apparently, you expect invariants to fail. They won't. Invariants never, ever fail. They are invariant. These assumptions are the cornerstones on which your algorithms are built. Adding code that throws an exception in case of an invariant failure is wasted, because that exception will never be thrown. Invariants are checked only during development. Release binaries typically don't contain those tests at all, i.e. assert() is disabled by compiling with the preprocessor symbol NDEBUG defined. Take care, Peter