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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!npeer.de.kpn-eurorings.net!npeer-ng2.kpn.DE!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Exceptions Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH 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> <1t9vga1zec55e.advo17w5as02.dlg@40tude.net> <475c1a15$0$30715$4d3efbfe@news.sover.net> Date: Mon, 10 Dec 2007 09:31:35 +0100 Message-ID: <1oxpbl7qkoevd$.1a6w7uneuk5q6.dlg@40tude.net> NNTP-Posting-Date: 10 Dec 2007 09:23:51 CET NNTP-Posting-Host: cca9d206.newsspool2.arcor-online.net X-Trace: DXC=ld0AW>;5gfhPXlQ;h]GTMdA9EHlD;3Ycb4Fo<]lROoRa4nDHegD_]ReMlAj7P:nCNbDNcfSJ;bb[eFCTGGVUmh?dLK[5LiR>kgb=;bLC26E?ia X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:18849 Date: 2007-12-10T09:23:51+01:00 List-Id: On Sun, 09 Dec 2007 11:38:46 -0500, Peter C. Chapin wrote: > Dmitry A. Kazakov wrote: > >> Then I would propose: >> >> begin >> P1 (X); >> exception >> when Empty_String_Error => >> -- do something else >> end; > > I only want X to contain a name from the database. I have to check for > that someplace regardless of what P1 wants to do. Checking for it inside > P1 doesn't work because P1 is a general purpose string handling > algorithm that knows nothing about my application. Then I didn't understand the example. If P1 does not check X why should it raise any exception? >> Isn't this indeed a waste of resources? Validation is performed twice, once >> in Has_Acceptable_Value and once in P1! > > In this example P1 doesn't validate. It just assumes the document is > valid and skips as much error handling as possible. However P1, or > subprograms it calls, might have the potential of raising a variety of > exceptions, including perhaps C_E if P1 is inadvertently given an > invalid document. In that case you just cannot say that P1 does not propagate Constraint_Error, because it is too difficult to spell the conditions of propagation. You put all trust in some Validate (X), which is designed independently on P1. How can you be certain that Validate indeed prevents Constraint_Error in P1? I would never do, so a handler for Constraint_Error looks quite appropriate to me. > In XML based applications I've written, I validate the document once and > then let the rest of the program just assume it is valid. OK, I would parse once, but that is another story. My point is that handler were a good idea because Validate and P1 are decoupled. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de