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!news1.google.com!news.glorb.com!indigo.octanews.net!news-out.octanews.net!mauve.octanews.net!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Sun, 09 Dec 2007 11:38:46 -0500 From: "Peter C. Chapin" 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> <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> In-Reply-To: <1t9vga1zec55e.advo17w5as02.dlg@40tude.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <475c1a15$0$30715$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: d94163c1.news.sover.net X-Trace: DXC=kjlNaB=QDa@0gYVRhloIOBK6_LM2JZB_C1GBGP8_K;EN3?@`i3kGa5KG^B\8aXQ0lO0AM[Q5_4XbE X-Complaints-To: abuse@sover.net Xref: g2news1.google.com comp.lang.ada:18815 Date: 2007-12-09T11:38:46-05:00 List-Id: 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. > 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 XML based applications I've written, I validate the document once and then let the rest of the program just assume it is valid. This means there are all kinds of error situations I can ignore because they aren't possible in a valid document. This lets me abbreviate not just one procedure (like P1), but many procedures. Peter