Dear,
I felt a bit disappointed while learning about the throw qualifier.
I think a more useful qualifier can be created in order to describe
the possible exceptions a method can throw, in the following way:
int TheClass::exceptMethod() _throw TheException {
throw TheException();
}
In this case, the gcc would check at runtime that the only exception
the method exceptMethod may throw is TheException.
Moreover
int TheClass::wrongMethod() _throw () {
exceptMethod();
}
should yield an error, since the exceptMethod() may throw the
exception TheException(),
but the qualifier _throw () indicates that no exception can arise from
calling wrongMethod().
However
int TheClass::correctMethod() _throw() {
try {
exceptMethod()
} catch (TheException) {
doSomething();
}
}
should correct, since the exception is catched.
I think that, if it is pessimistically supposed that every exception
not enclosed into a try { } catch { } block may be thrown, the check
can be done at runtime.
The overall idea is, of course, to give information to the caller
about the exceptions it must handle.
I think that this extension would worth the while. Any ideas?
Cheers,
Sergio