[Exceptional C++ Style] Item 13: A Pragmatic Look atExceptionSpecifications

Kevlin Henney kevlin at curbralan.com
Tue Dec 7 18:41:11 EST 2004


In message <065201c4dc5f$531893e0$1801a8c0 at evaluategroup.local>, Adrian 
Fagg <adrianf at evaluategroup.com> writes
>
>Yes, on the face of it, one would think so. As I understood it, they
>chickened out of it for probably quite good reasons.
>I would argue that although outwardly attractive, exception specifications
>were a mistake beyond the simple no throw and I'm not completely convinced
>by even that.
>The real problem is the coupling implicit in exception specifications, which
>I think is the show-stopper.

It is the coupling of a potentially uncertain and unstable concept (what 
are the likely modes of failure that should be advertised for this 
function?) with a more certain and stable concept (what is the intent of 
this function?). The intent is expressed, wrt the type system, through 
the name, arguments and return type of the function and tends to be far 
more stable than the understanding of failure modes, which evolves over 
time. Putting exception specs in the type system drags the more stable 
idea along with it, making the whole interface less stable.

Kevlin
-- 
____________________________________________________________

   Kevlin Henney                   phone:  +44 117 942 2990
   mailto:kevlin at curbralan.com     mobile: +44 7801 073 508
   http://www.curbralan.com        fax:    +44 870 052 2289
   Curbralan: Consultancy + Training + Development + Review
____________________________________________________________



More information about the Effective-cpp mailing list