On Sun, 17 Nov 2002 18:22:20 +0100, Thorsten Ottosen <[EMAIL PROTECTED]> wrote:
>Yes, but note that having both is less fortunate. Either we agree that >library writers check preconditions and then >clients don't or we agree that clients check preconditions and library >writers don't. One reason that C is such >a pain in the *** to use is because its the cliets responsibility to check >conditions , e.g. > >int * i = malloc( sizeof( i ) ); >assert( i ); Well, apart from the C-style void*->int* conversion and the curious sizeof(i) instead of sizeof(int), weren't you speaking of preconditions? :-) Anyhow one of the reasons why C++ (or C if you want to talk about it) is the way we all know is that it does its best to avoid unnecessary costs: "you do not pay for what you don't use". In a situation where you are absolutely sure that no precondition is violated you don't want the library to check that for you. C++ programmers are not the kind of guys who like range-checking on vector::operator[] when they have something like: for (std::size_t i = 0; i < v.size(); ++i) std::cout << vect[i] << '\n'; That's way generally libraries don't check in 'non-debug mode'. OTOH, it's obvious that strictly speaking there's no "debug mode" built-in into the language either so your problem of "over-checking" (if it is a problem) is actually in the scope of the contract between the user and the library itself (That is: library xyz can tell you that, when NDEBUG is not defined, it asserts on precondition violations for you). Maybe, we could encourage library writers to document such a fact? Peter? Genny. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost