From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7d3cb5920e882220 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Exceptions Date: Mon, 10 Dec 2007 20:12:03 -0600 Organization: Jacob's private Usenet server Message-ID: References: <5947aa62-2547-4fbb-bc46-1111b4a0dcc9@x69g2000hsx.googlegroups.com> <475c6ed8$0$13111$9b4e6d93@newsspool2.arcor-online.net> <1kxk3hlfa25dw$.fl2wvbn0tpbg$.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1197338909 29767 69.95.181.76 (11 Dec 2007 02:08:29 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 11 Dec 2007 02:08:29 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 Xref: g2news1.google.com comp.lang.ada:18885 Date: 2007-12-10T20:12:03-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:1kxk3hlfa25dw$.fl2wvbn0tpbg$.dlg@40tude.net... ... > 1. How often do you declare a new exception when writing a new subprogram? > My guess is about 1 / 10_000. For me, it is more like 1/100. Most subsystems get their own set of exceptions. > 2. How often does a caller "eat" an exception of the callee instead of > propagating it further? My guess is 1 / 10. This I agree with, and it is my primary objection to exception contracts. This means that you'll have to write long-winded handlers and/or contracts on 9/10 of the calls. That is, it is the common case that takes more work. That's usually bad. > There is not that many handlers in a good designed code. This is probably > the reason why people forget to handle exceptions properly. They are not > that visible. That's true: a lot of systems that I write have no handlers at all because any exception being raised is a bug, and I want to know. The biggest problem is insuring enough test coverage to make sure that the (latent) exceptions (that is, bugs) get raised. Most of the handlers I do write are of the form: begin Open (...); -- File or socket or ... exception when others => -- Couldn't open whatever. Abort program or process. end; -- Use the open file. But I'm not usually writing safety-critical systems. For programs that need to keep running (for example, a mail server), I use a single global others handler that logs any exceptions, since there should be none. But there would no way to prove that statically, and I don't think I'd want to have to write code structured to be able to try. Randy.