From: David Abrahams (dave_at_[hidden])
Date: 2008-07-28 20:57:16
on Mon Jul 28 2008, "Emil Dotchevski" <emil-AT-revergestudios.com> wrote:
>>>> Assertions are for precondition violations -- they detect programming
>>>> errors. Exceptions are for failure to satisfy postconditions. They're
>>>> really very different.
>>> Since we don't have a category for detecting and reporting failures,
>>> it seems a good idea to create one. I'm all for a better name for it,
>>> of course.
>>> The problem is that the exception lib doesn't belong in any of the
>>> existing categories, except maybe the Miscellaneous category. :)
>> Well, maybe that's where it belongs. static assert and Boost.Test are
>> in the category of something like "program validation and testing" and
>> don't belong in the same category as something designed for dealing with
>> resource exhaustion and other essentially non-preventable and
>> (hopefully) recoverable conditions.
> Yes, exceptions are used to enforce postconditions,
"Enforce" isn't the best word; they bail you out when you're not going
to meet postconditions, so you can avoid failure.
> but this doesn't contradict the view that exceptions are used to
> report failures (to meet postconditions).
You might notice that I said "exceptions are for failure to satisfy
postconditions" above :-)
That said, they're really for avoiding failure, as noted in this message.
> There are different kinds of failures,
Radically. And people tend to collapse them in their minds.
> but despite the differences there is some commonality between asserts,
> static asserts, exceptions, signals, std::cerr, logging, abort(),
> exit(), etc. Naming a category "error reporting" seems to capture
> that, and it seems more descriptive than "miscellaneous" (and from
> that point of view static assert would belong to both "error
> reporting" and "program validation and testing".)
How about "diagnostics?"
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk