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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9b2046241520981f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-26 09:01:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.airnews.net!cabal12.airnews.net!usenet From: "John R. Strohm" Newsgroups: comp.lang.ada Subject: Re: Ada 0x, exception idea ? Date: Sat, 26 Jul 2003 10:53:49 -0500 Organization: Airnews.net! at Internet America Message-ID: References: Abuse-Reports-To: abuse at airmail.net to report improper postings NNTP-Proxy-Relay: library1-aux.airnews.net NNTP-Posting-Time: Sat, 26 Jul 2003 10:58:35 -0500 (CDT) NNTP-Posting-Host: !^^<@1k-Y8JfJ]p (Encoded at Airnews!) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Xref: archiver1.google.com comp.lang.ada:40843 Date: 2003-07-26T10:53:49-05:00 List-Id: "sk" wrote in message news:mailman.0.1059231120.320.comp.lang.ada@ada.eu.org... > Hi, > > IDEA > > when raise ; > > OR > > when then raise ; > > OR > > raise when ; > > SITUATION > > Call_Condition_Setting_Procedure (Paramters, Success); > > if not Success then > raise Call_Failed; > end if; > > > REPLACED BY > > Call_Condition_Setting_Procedure (Paramters, Success); > > when not Success raise Call_Failed; > OR > when not Success then raise Call_Failed; > OR > raise Call_Failed when not Success; > > > Thoughts ? > > (This is a ghost of Timex/Sinclair Basic "ON ERR GOSUB" (sorry to > pollute with the "B" word :-)). Bletch. As you observe, your proposed constructs are precisely equivalent to call_procedure(..., success); if not success then raise call_failed; end if; Ada in general does not bother with unnecessary syntactic sugar, which is what this is. Second, and more general: If an exception should be raised SOME of the time when the procedure fails, it probably should be raised ALL of the time, and then the procedure itself should raise the exception, not set a status flag and rely on the caller to check the flag and raise the exception if necessary. Observe that raising the exception inside the procedure is more robust: it REQUIRES every caller to be prepared to trap the exception, and hence handle a potential error case. (One of the more common errors made by C programmers is forgetting to check a pass/fail status return parameter.)