Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-08-13 07:54:53


----- Original Message -----
From: "Reid Sweatman" <borderland_at_[hidden]>

> I went over the sections on exceptions in Stroustrup 3rd last night, and I
> think I understand what you're saying now. That does seem a more
> intelligent way to use exceptions than the limited form I've been using.
I
> still think I would use them for local problems involving more than a few
> lines of code, just for consistency's sake.

That's legitimate.

> Yes, a broken precondition
> should be fatal, whereas a class-invariant problem may not be.

Er, how so? If a class invariant is broken, the precondition to any of its
member functions is broken, too.

> It now seems
> to me that the exception mechanism is more a method of signalling safely
up
> the call chain, than just an error-handler (without working like signals,
of
> course), so I guess any reasonable usage that keeps the program running
> without too much of a performance penalty, or shuts it down when something
> fatal happens is okay to do. Should have looked at Stroustrup to begin
> with; I read the 2nd edition a couple of times way back when, but acquired
> the 3rd during a high-stress period, and didn't immediately form the habit
> of checking it first. I have probably too much tendency to use the C++
FAQ
> 2nd; that's where I got my original ideas on exceptions.

Only Stroustrup's very latest printing of C++PL 3rd edition contains his
latest writing on exceptions. But you can also find it online at
http://www.research.att.com/~bs/3rd_safe0.html. I think there are still a
couple of errors in there so you can pick up an "editor's bounty" if you
read carefully ;)

> > > I'm beginning to understand why some people here aren't too gung ho on
> > > exceptions to begin with.
> >
> > I don't understand that last bit.
>
> I was just referring to the arguments that have gone on sporadically in
the
> past here about throw decorations. It's mostly concerned empty
> specifications, but there were some arguments against using them at all.
I
> didn't mean that anyone here considered them unusable; it's just difficult
> to know when an exception mechanism is the way to handle a problem. But
> thanks to your explanation, I think I have a better handle on it now.

That's a different question altogether. I'm one of those people who jumps up
and down about how dangerous exception-specifications are. My advice is: go
ahead and use exception-handling, but stay away from
exception-specifications unless you've thought very hard about the
consequences. Then think again before you use them.

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk