From 6324752238084939402 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,ed5c0a968491d47d X-Google-Attributes: gid109fba,public X-Google-Thread: f78e5,ed5c0a968491d47d X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 1991-11-11 11:08:21 PST Path: gmdzi!zeus.ieee.org!dorm.rutgers.edu!rutgers!cs.utexas.edu!wupost!uunet!igor!erde!rmartin From: rmartin@erde.Rational.COM (Bob Martin) Newsgroups: comp.lang.c++,comp.std.c++ Subject: Re: C++ exception handling model Message-ID: Date: 11 Nov 91 17:46:48 GMT References: <1991Nov8.141843.6034@cc.ic.ac.uk> Sender: news@Rational.COM Followup-To: comp.lang.c++ Lines: 63 Xref: gmdzi comp.lang.c++:56361 comp.std.c++:1203 rb@cc.ic.ac.uk (Robin Becker) writes: >A recent issue of .EXE magazine contains an article on C++ exceptions >(I can't remember the author's name apologies :-) ) and pointed out >the following problems. > 1) C++ exception handlers are defined by a type which can > lead to problems with libraries. I.e. we both want > to use the same type. This is a problem with C++ Classes in general. There is no way to hide a cohesive set of class names within an isolated context. (nested classes might seem like a way to do this, but they can't really be used for large scale groupings.) This inability to hide a group of classes means that we are exposed to name clashes whenver we integrate someone elses software with our own. This makes it hard to use two or three different vendor's products toghether... I view this as a severe problem which needs to be solved before the language can be viewed as complete... > 2) C++ has problems when one doesn't want to use the > termination model for the handler, i.e. you can't > resume the processing at the original exception point. I suppose that's true. One cant simply return from a catch and start executing right below the throw. I'm not sure allowing that would be such a good idea anyway. But one can easily implement "try-again" models: void f() { int keepTrying = 1; while (keepTrying) { try { /* do some work */ keepTrying = 0; } catch (Fixable& f) { /* fix the problem */ keepTrying = 1; // JFTHOI } catch (UnFixable& u) { /* prepare to terminate f */ keepTrying = 0; } } } -- +---Robert C. Martin---+-RRR---CCC-M-----M-| R.C.M. Consulting | | rmartin@rational.com |-R--R-C----M-M-M-M-| C++/C/Unix Engineering | | (Uncle Bob.) |-RRR--C----M--M--M-| OOA/OOD/OOP Training | +----------------------+-R--R--CCC-M-----M-| Product Design & Devel. |