There seem to be some arguments floating around about why it may not be a good idea to implement compile time checking of exception specifications. However, I'm not sure that I agree with these arguments.

I think the purveyors of these arguments have the point of view that any such feature would have to be a compile-time error generation feature, which, like Java, would do an exhaustive search of all exception information. What I would like to see is a feature that generates warnings to the user and only operates on those functions/methods that participate in the exception specification mechanism.

The key thing to realize is that a function that does not specify an exception specification can be safely ignored -- this makes us no worse off than we currently are. The warnings generated by the compiler could focus exclusively on those functions that do have exception specifications. This narrows the field and allows for a fairly simply system by which a user can receive a great deal of useful information about functions that participate in the exception specification mechanism.

Another common argument is that there may be code that looks like it would violate the exception specification, but through further analysis of the code, actually would not. A very simple example of this would be:

void bar() { throw MyException(); }
void foo() throw(MyException) {
   bar();
   throw AnotherException();
}

My answer: who cares? Many other warnings in the compiler have the same issue. In addition, as a developer, I would want to know about the possibility of an exception specification violation (especially if the function body of bar() was changed to not throw a MyException()).

So, to some up, I think that a very useful exception specification warning feature could be added to the compiler that would catch the majority of programming errors that the developer would be interested in. Also, given that we would only be examining functions that had exception specifications in their signature, it would be a fairly straightforward feature to implement.

Sincerely,
Kevin Regan

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

Reply via email to