From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=BAYES_00,XPRIO autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Code flow control Date: Fri, 15 Oct 2021 17:51:41 -0500 Organization: JSA Research & Innovation Message-ID: References: <23031592-5a56-4d56-bda7-34877588802dn@googlegroups.com> Injection-Date: Fri, 15 Oct 2021 22:51:42 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="596"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:63017 List-Id: "Kevin Chadwick" wrote in message news:23031592-5a56-4d56-bda7-34877588802dn@googlegroups.com... On Friday, 15 October 2021 at 21:02:49 UTC+1, G.B. wrote: > On 15.10.21 20:03, Dmitry A. Kazakov wrote: > > On 2021-10-15 19:48, J-P. Rosen wrote: >> >> Some people reserve exceptions for signalling errors. I regard them as >> >> a way to handle "exceptional" situations, i.e. when the normal flow of >> >> control cannot continue. For example, in a deep recursive search, they >> >> are handy to stop the recursion and go back to top level when you have >> >> found what you were looking for. Some would disagree with that. >> > >> > I strongly believe that this is the only consistent way to treat >> > exceptions. >> Once found, pass the result to the party that needs it. >> Then, finish the computational task that found the result. >> Is there anything besides exceptions to do that, and orderly? >I believe the ada 95 style guide recommended a standard goto? Gotos only work within a single invocation of a single subprogram. It is rarely the case that some complex computation only uses one subprogram, and that's never the case in a recursive search (the example that J-P gave). A program that tries to handle end-of-file by calling End_of_File all over is (a) way more complex than necessary, and (b) likely to be wrong as some case is missed. Handling End_Error makes way more sense. Of course, if you *are* in a single subprogram, then the advice of the style guide is good (exceptions having more overhead than gotos, especially when they actually occur). They're best used when multiple subprograms (or subprogram calls) are involved. Randy.