From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 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: Ada and "early return" - opinion/practice question Date: Tue, 16 Mar 2021 02:17:02 -0500 Organization: JSA Research & Innovation Message-ID: References: <38356aa9-b8b0-4e0b-a490-99e7b239d0b1n@googlegroups.com> <87im5sutdt.fsf@nightsong.com> Injection-Date: Tue, 16 Mar 2021 07:17:04 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="3426"; 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:61544 List-Id: "Paul Rubin" wrote in message news:87im5sutdt.fsf@nightsong.com... > Shark8 writes: >> Exceptions, typically. Sometimes a return itself, typically in a >> procedure though. > > This is interesting: I thought in the Java and C++ worlds, using > exceptions to manage normal control flow was frowned on, ... We're not talking about "normal control flow" here; we're talking about error conditions that typically represent a programming mistake. It's fine to use exceptions for that, because they should never occur. When they do, you don't really care how expensive they are (again, because they're rare). If you have a normal case (such as not finding anything in a search), using exceptions would generally be considered wrong. Using them would break up cases that are logically related. Ada does take a more flexible approach though. Most Ada programmers would rather handle the exception End_Error rather than fill their program with tests for end-of-file before every read. I/O is messy enough without putting the boundary conditions everywhere (or worse yet, *ignoring* the boundary conditions). So no completely hard-and-fast rule for Ada. Randy.