(ref.doc)daniels 040294

Next bs 080294 Prev: rmartin 030294 Up: Usenet

Newsgroups: comp.std.c++
From: [email protected] (Brad Daniels)
Subject: Re: Exceptions: enforcement of throw() signatures?
Date: Fri, 4 Feb 1994 19:57:30 GMT

In article <[email protected]>,
Stan Friesen <[email protected]> wrote:
...
>Think about the case where fred() calls george() which calls sam()
>which calls ... which calls libmatrix::determinant() which calls
>some private routine in the matrix library, which throws an exception.
>How is the compiler to detect this???  Searching the entire call tree
>is prohibitively expensive, and restricting fred() to calling routines
>with the same exception signature except in try blocks with a catch(...)
>clause is too restrictive of the programmer.
...

I think it should be done exactly that last way, and I don't think it's too
restrictive.  Exception signatures are meaningless if they are not enforced,
and if they are enforced at run-time, I have exactly the same restrictions
on my routine as those you say are too restrictive, except that I may not
find out I've violated the restrictions until the program is out running some
critical control operation and dies from an exception signature violation.

If exception signatures are to be part of the language, they should be
enforced by requiring every routine to conform to its signature at compile
time (by only allowing calls to functions with the same signature unless the
call is within a try block which catches all non-conforming exceptions and
prohibiting them from throwing exceptions outside their signatures.)  If they
are not enforced at compile time, they serve either as a documentation aid,
in which case comments would do as well, or as a source of unexpected run-
time errors, in which case they are an unsafe and undesirable feature.



automatically generated by info2www version 1.2.2.8