From: Dan W. (danw_at_[hidden])
Date: 2004-01-03 02:52:39
>>Precisely, the DBC
>>'fuses' are only compiled in debug mode because you don't want to stop
>>the application out there in the real world.
> Often it is better to terminate() than letting a program continue on
> undefined behavior; especially in
> languages with unsafe pointers.
That's what I've been saying all along. OFTEN, but not always. That's
why you want to use exceptions, and have a *policy*. And preferably a
run-time customizable policy.
But I've also been saying, DBC has only one policy: to stop execution.
And the intent for DBC is to help debug as well as document. It is not
meant to replace exceptions.
Using exceptions for debugging sucks. Exceptions are good at dealing
with exceptions in the field, not with bugs.
DBC is for dealing with bugs, NOT with exceptions in the field.
That's why I've been saying _please_forget_exceptions_ when talking
about implementing DBC. Just leave them alone. Let's just talk DBC.
Which is for dealing with bugs.
But everybody suddenly wants DBC to handle exceptions, to throw notices
on the screen, to log problems to a file...
There are other tools that are more appropriate to all those other things.
DBC all it does is express what things must hold true about a class,
that a loop should converge, what a function can do, and what it needs
in order to do it. It is fine-grained, ubiquitous, you rarely need to
single-step code in the debugger, because, at the beginning, DBC
contracts will stop your debugger in many places, and where it doesn't
stop your code, it probabaly means your code is correct. And that's what
DBC is for, so that you're not single-stepping through the whole
program, and trying to understand and verify every variable by eye, but
rather let DBC stop you where your attention is needed. And when you're
done with this process, the DBC code is the best documentation you could
ever write for your code. It is detailed, concise, and concurrent.
But does DBC handle exceptions? No it doesnt..
Does that mean exceptions are bad? No it doesnt...
Apples and Bananas. That's all.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk