Avoid interface specification

One syntactical element you should not use is the interface specification, see xa4 9.6 of The C++ Programming Language (Stroustrup). This specifies, in a function declaration, those exceptions the function can throw. It looks like this:

    void Foo(int) throw(a, b, c);
If an exception that is not in the list is thrown, the default action is to terminate the program. Because exception handling should be robust against errors, this is counterproductive. To correctly use this feature, you must list all unhandled exceptions that can be thrown by any called function (direct or indirect); this is impractical. For example, a disk error might cause a high-level application action to be unsuccessful. If you use interface specification, disk error must appear in every function declaration in the call chain.

Any exception thrown by the Taligent Application Environment should be a descendant of TStandardException, so assume that any function can throw a TStandardException (similar to Stroustrup's hypothetical Fail exception). After all, you can always do something sensible with a TStandardException, including produce an error message.

Taligent engineers use interface specification only with an architect's approval.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker