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!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Exceptions Date: Sun, 09 Dec 2007 16:56:58 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <5947aa62-2547-4fbb-bc46-1111b4a0dcc9@x69g2000hsx.googlegroups.com> <475a8d6d$0$30677$4d3efbfe@news.sover.net> <145gsya555jlt$.8mvve9nqja9n$.dlg@40tude.net> <475adbe8$0$30689$4d3efbfe@news.sover.net> <1qbsb1u76vyrk.3n8oov6aevw3$.dlg@40tude.net> <475be24c$0$30661$4d3efbfe@news.sover.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1197237418 28521 192.74.137.71 (9 Dec 2007 21:56:58 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 9 Dec 2007 21:56:58 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:UxrcgXCkxiymkxUE8WzOouI/NC0= Xref: g2news1.google.com comp.lang.ada:18831 Date: 2007-12-09T16:56:58-05:00 List-Id: "Peter C. Chapin" writes: > 2. X is an abstract type representing an XML document. > Has_Acceptable_Value returns true if X is valid according to its > declared schema. P1 does some XML processing but it assumes the document > given to it is well formed and raises exceptions if that is not the > case. Since valid documents are also well formed, those exceptions won't > occur once Has_Acceptable_Value has signed off on X. Indeed, this is one > of the main reasons why validating documents before processing them is > desirable: it simplifies later error handling. Right. A similar example is a compiler. E.g. in GNAT, the semantic analysis phase assumes that the tree produced by the parser is syntactically correct. And the code generator assumes that the program is legal. > Suppose the above is inside a loop that runs over a collection of > documents. Do we really want to include a handler for > Not_Well_Formed_Exception in this procedure just because the contract on > Process_Document says it might raise such an exception? Well, we at least want a comment saying why the exception that "might" be raised will not be raised in this case. And "when Blah => raise Bug; -- ..." seems like a good way to say that. >...Do we really > want to claim that we propagate that exception when we clearly don't? No. That would spread noise around the whole program. > You might say that in a careful program (for example in a high integrity > program) unexpected exceptions should not be treated in such a cavalier > manner. I would agree with that. The question is should the language > attempt to force that degree of care on all programs? It's a balance > between usability and safety. As with all things related to security, > overly aggressive policies can backfire when people feel the need to do > silly things to work around them. I suppose at the end of the day it's > really just a matter of taste... which is what makes debates like this > possible. :-) How can it be a matter of taste? Checked exceptions either improve the code or they don't. Maybe it depends on the application area. But I don't see how it can depend on taste. - Bob