Re: [Fresco-devel] Coding standard: throw specifications

Nathaniel Smith <[email protected]>
Newsgroups gmane.comp.video.fresco.devel
Message-ID <[email protected]>
On Sun, Jan 05, 2003 at 10:12:42AM +0000, Neil Pilgrim wrote:
> Hi all,
> 
> a) Is there some policy regarding throw specifications? I ask, since
> while idl uses them, I understand that generally people do not use them
> in C++. I think they are already used in fresco elsewhere; should we
> continue to use them or not? I haven't checked whether implementations
> of idl functions with throw specifications must also have a throw spec
> in C++...

Throw specifications mean very different things in IDL and C++
(reasonably, considering that the exception handling systems are
totally different too...).  In IDL, throw specs are a way of
_enabling_ exceptions -- you can only throw exceptions that you have
throw specs for.  In C++, throw specs are a way of _disabling_
exceptions -- you guarantee that you'll never throw any exception
besides those listed (enforced by crashes, IIRC).  The two systems are
quite orthogonal.

There's, on average, a bias against using them in C++, because
normally you should let exceptions propagate to the best place to deal
with them; throw declarations used incautiously can interfere with
this and make for worse error handling.  That doesn't mean that you
shouldn't use them, though, just be careful and use them where it's a
good idea :-).

In IDL, of course, it's a different beast; use them whenever you want
to let a method throw an exception (and throwing an exception is
generally considered to be a good way to signal an error, no?).

> b) Should the decision of this be added to the coding standard? Latest
> version is at http://www2.fresco.org/coding-style.html (*not* www, only
> www2).

I don't think it's a style issue so much as an API design issue, and
as such seems beyond the scope of the coding guidelines.

-- Nathaniel

-- 
Damn the Solar System.  Bad light; planets too distant; pestered with
comets; feeble contrivance; could make a better one myself.
  -- Lord Jeffrey

This email may be read aloud.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.