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!news3.google.com!news.germany.com!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Exceptions Date: Thu, 13 Dec 2007 13:29:17 -0600 Organization: Jacob's private Usenet server Message-ID: References: <5947aa62-2547-4fbb-bc46-1111b4a0dcc9@x69g2000hsx.googlegroups.com> <475c688f$0$17524$9b4e6d93@newsspool4.arcor-online.net> <4dae26fe-0c8a-46e1-9a33-43c18cf757ae@i3g2000hsf.googlegroups.com> <9f16235c-260a-460b-873c-2183c154cc0c@e25g2000prg.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1197573941 13352 69.95.181.76 (13 Dec 2007 19:25:41 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 13 Dec 2007 19:25:41 +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:18929 Date: 2007-12-13T13:29:17-06:00 List-Id: "Maciej Sobczak" wrote in message news:9f16235c-260a-460b-873c-2183c154cc0c@e25g2000prg.googlegroups.com... > On 13 Gru, 14:40, Robert A Duff wrote: ... > > I don't consider Constraint_Error "mere", by the way. > > It almost always represents a bug. > > What about a situation when a user entered an input data that was > outside of legal (and documented) range? Or that caused our of range > value further down the pipe? > This is not necessarily a bug, just an indication that the value is > out of range. The exception can help to come back to the input loop > and repeat the user scenario, abandoning all the state that was > created in the meanime. This way the program does not enter into any > abnormal state. An *unhandled* Constraint_Error represents a bug - in this case, a lack of appropriate input validation. One can handle it very locally for that purpose, although I prefer to input values into maximum size objects and check the range with a membership before converting it. (That way, that there is in fact validation is clearer.) Even the propagation of Constraint_Error represents a bug. Exception contracts would help with detecting that, but only if the rules were strong enough that it is possible to write reasonable code that is exception-free. Having Java-style "unchecked exceptions" defeats the purpose. Randy. P.S. Sorry about the old responses just appearing now; something happened to the news server while I was answering those on Monday, and it didn't work again until now.