🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #723

Re: Exception Specifications

#723
From: Jerry Schwarz
Date: Wed, 30 Sep 1992 20:56
51 lines
2770 bytes
First a little history.

When exceptions were accepted by
X3J16 there were some of us (including myself) who though (like Scott)
that exception specifications were useless.  However, there were
also many who felt they were essential to good programming.
The later included the only people (a medical software group at HP)
with experience using exceptions in C++. I asked them whether "out
of memory" had to always be included on their lists and they said
they didn't treat "out of memory" as an exception.

The people who liked failure clauses would have prefered that
the default condition be the same as an empty failure list.
That is if you don't say that a function can throw an exception
then it can't.  The result was a compromise, failure clasues are allowed,
but the default is to allow functions without them to throw any
exception.

-----
Now my opinion.

My impression is that if you design your system from scratch
(including all libraries) with failure clauses on all function
declarations and your compiler checks them for consistency
you gain some useful compile time type checking.  But in 
other circumstances there is little gained.

At the moment X3J16 is considering the implications of exceptions
for stream classes.  Some think that streams should only
be able to throw a particular kind of exception (tentatively
named ios::failure). Others (including myself) feel that a stream
should be able to throw an arbitrary exception. Remember, users
can define their own kinds of streambufs, so X3J16 can't know in advance
what kinds of conditions they might want to report.  

My intuition (not based on experience I confess) is that in
general it is more important to get specific information about
the conditions that caused an exception than it it to know that
it in occured in some stream operation. That is, it is better to
know that there was an "out of memory" or "database corruption" problem
than it is to know that there was a problem while doing a stream
operation.  This leads me to the conclusion that the iostream library
should not use failure clauses.
 
  -- Jerry Schwarz

Please. No followups about how throwing exceptions by streams
will break existing programs.  We're aware of that.  By default
streams will throw (almost) no exceptions and will catch any thrown
by a streambuf.
Technical Details
Message-ID: <1992Sep30.205656.10646@lucid.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
References: <1992Sep29.201603.19289@cs.brown.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
From: jss@lucid.com (Jerry Schwarz)
Subject: Re: Exception Specifications
Message-ID: <1992Sep30.205656.10646@lucid.com>
Sender: usenet@lucid.com
Reply-To: jss@lucid.com (Jerry Schwarz)
Organization: Lucid, Inc.
References:  <1992Sep29.201603.19289@cs.brown.edu>
Date: Wed, 30 Sep 92 20:56:56 GMT
Lines: 58