Re: assertions: does it matter that they are disabled in production?
On 9 Aug., 17:59, Walter Bright <wal...@digitalmars-nospamm.com>
wrote:
marlow.and...@googlemail.com wrote:
Does this mean C++ programmers don't like such a C-like mechanism? Or
they don't don't like the fact that the assertions are disabled in
production? Or is there some other reason?
I use them in the production release, and find them to be very effective
at finding bugs.
So perhaps you ship to early? ;-)
If I am to be more serious, something like "assert" can be quite
useful in production code. The problem is that assert in my opinion is
to coarse and perhaps to badly defined (I would not like a debugger to
be opened when the customer tries to run my code).
Some asserts are useful to leave in, but others are better left out. A
typical example is verification of code: assume you write a smart
o(log n) algorithm to replace your current o(n). In those cases, I
validate my new algorithm against the old one, but the result is that
your code gets slower, not faster. Using assert to validate this is
clearly a bad idea.
/Peter
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]