From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10f8a1,e7e13c943c611b62 X-Google-Attributes: gid10f8a1,public X-Google-Thread: 1164f8,be3d6a6131c61fa7 X-Google-Attributes: gid1164f8,public X-Google-Thread: 102b75,be3d6a6131c61fa7 X-Google-Attributes: gid102b75,public From: dpbsmith@world.std.com (Daniel P. B. Smith) Subject: Re: Exception handling Date: 1999/04/24 Message-ID: #1/1 X-Deja-AN: 470383294 References: <36E9F2A0.9A401A09@pacific.net.sg> <924046418.053.46@news.remarQ.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.arch,comp.sys.dec,vmsnet.alpha >Zalman Stern wrote: >> >>Languages with exception handling pretty much eliminate the desire to do >>the above. Given that this technology has been in common use for more than >>a decade, you'd think it would be more or less adopted by now... > > The languages I know with exception handling (C++, Java) have been >designed sufficiently poorly that lots of people still don't want to >use them. Having spent a lot of time with languages in which you can use a "functional" approach, and have function return big, juicy, rich, complex things, I've always disliked the C style in which any possibility of returning anything useful through a function value is preempted by the need of using the function value as a mechanism for signalling exceptions. So when I started to use C++, I used exception handling all over the place... and, IF I understand correctly, I've thoroughly screwed myself by doing so. However, enlightenment on this would be welcome. IF I understand correctly, the gotcha--one that Stoustrup's book doesn't explain or warn you against--is that the compiler code generated for exception handling is not standardized and not necessarily interoperable, either with code generated by C compilers or code generated by _other_ C++ compilers. Therefore, you cannot use exception handling at all unless you can guarantee that _all_ code in your program was generated by the same C++ compiler. In my case: I write "front-end" code; the code calls a library, which is provided by the company we are OEM-ing from; the library in turn makes callbacks to "back-end" routines that I provide. The library is documented as if were written in C, and their code examples are in C. But, silly me, I thought that backward compatibility with C was almost C++'s whole reason for being, and that I was reasonably safe mixing and matching as long as I used extern "C" directives properly in my headers. I _did_ wonder why the program crashed whenever one of my callback routines threw an exception... -- Daniel P. B. Smith dpbsmith@world.std.com