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!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!newsfeed01.chello.at!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Mon, 10 Dec 2007 10:20:38 +0100 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Exceptions References: <5947aa62-2547-4fbb-bc46-1111b4a0dcc9@x69g2000hsx.googlegroups.com> <475c6ed8$0$13111$9b4e6d93@newsspool2.arcor-online.net> <1kxk3hlfa25dw$.fl2wvbn0tpbg$.dlg@40tude.net> In-Reply-To: <1kxk3hlfa25dw$.fl2wvbn0tpbg$.dlg@40tude.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <475d04ea$0$13113$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 10 Dec 2007 10:20:42 CET NNTP-Posting-Host: a9cb9dd0.newsspool2.arcor-online.net X-Trace: DXC=16S_\>omR1UaAeROF2PWMQA9EHlD;3YcR4Fo<]lROoRQ4nDHegD_]RUARfOGfY2]l_A:ho7QcPOVSaY4KE8OB17\j_l0d];XN\^ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:18852 Date: 2007-12-10T10:20:42+01:00 List-Id: Dmitry A. Kazakov wrote: >> >> Now, when we have a sequence of statements in a block, >> >> P1(X); P2(X); ... ; Pn(X, Y); >> >> then what will be the average number of exception handlers >> for this block? Involving how many different exceptions? > > Close to 0. > > 1. How often do you declare a new exception when writing a new subprogram? > My guess is about 1 / 10_000. OK, assume programmers will declare new exceptions only for 1 / 10_000 subprograms. procedure P1(X: Temperature) raise Constraint_Error; procedure P5(X: Pressure) raise Constraint_Error; begin P1(Hot); P5(Deflated); exception when Constraint_Error => ? end; Do programmers put a block around every procedure call so that the proper occurence of Constraint_Error is handled? And will this likelyhood increase once subp declarations announce foreseeable exceptions? > 2. How often does a caller "eat" an exception of the callee instead of > propagating it further? My guess is 1 / 10. Are you assuming current rules for guessing 10% exception handling, i.e., no exceptions are announced by the subprogram declaration? > There is not that many handlers in a good designed code. Hear, hear. [Q] Why do we need more exception announcements, then? Will design improve because of subp with exception announcements? > This is probably > the reason why people forget to handle exceptions properly. They are not > that visible. If programmers do not handle exceptions properly when they do not see them in source, will forcing them to handle exceptions make them handle exceptions _properly_? I have seen a number of null handlers... My guess is that missing else branches or undocumented null "others" in case distinctions are a related issue. The issue really is handling cases, not announcing them. Every if implies the possibility of an else. Still we can have null else branches (or "others" choises). If only the Algol symbol "comment" had been given more emphasis in successor languages. A friendly tell-us-what-you-think! mechanism is better IMHO than a combination of force together with a force absorbing mechanism! (Exception "contracts" together with null handlers and the like.) case Traffic_Light is when Red => ... ; when Green => .... ; when others => comment No comment; null; -- forces the comment. -- Hypothesis: the comment "No comment" will not -- pass quality control end case; Remove "others" from the languge? :-)