comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Ada and "early return" - opinion/practice question
Date: Tue, 16 Mar 2021 02:17:02 -0500	[thread overview]
Message-ID: <s2pm1f$3b2$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 87im5sutdt.fsf@nightsong.com


"Paul Rubin" <no.email@nospam.invalid> wrote in message 
news:87im5sutdt.fsf@nightsong.com...
> Shark8 <onewingedshark@gmail.com> 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.


  parent reply	other threads:[~2021-03-16  7:17 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 16:46 Ada and "early return" - opinion/practice question John McCabe
2021-03-15 17:02 ` Dmitry A. Kazakov
2021-03-15 17:29   ` John McCabe
2021-03-16  7:08   ` Randy Brukardt
2021-03-15 17:31 ` Stephen Leake
2021-03-15 17:43   ` John McCabe
2021-03-15 18:15     ` Shark8
2021-03-15 20:39       ` Simon Wright
2021-03-15 20:56         ` Chris Townley
2021-03-16  7:19           ` Stéphane Rivière
2021-03-16 10:31             ` Jeffrey R. Carter
2021-03-16  8:28           ` John McCabe
2021-03-16 20:34         ` Simon Wright
2021-03-17  8:05           ` John McCabe
2021-03-17 11:43             ` Simon Wright
2021-03-18  8:08               ` John McCabe
2021-03-18 16:27                 ` Stephen Leake
2021-03-20 13:41                   ` John McCabe
2021-03-15 19:05     ` Paul Rubin
2021-03-16  8:38       ` John McCabe
2021-03-16  9:03     ` Stephen Leake
2021-03-16  9:21       ` John McCabe
2021-03-16  8:24   ` John McCabe
2021-03-16  9:13     ` Stephen Leake
2021-03-16 11:51       ` John McCabe
2021-03-16  9:46     ` Dmitry A. Kazakov
2021-03-16 10:46     ` Jeffrey R. Carter
2021-03-17  8:18       ` John McCabe
2021-03-17 10:06         ` AdaMagica
2021-03-15 18:12 ` Shark8
2021-03-15 18:20   ` John McCabe
2021-03-15 19:08   ` Paul Rubin
2021-03-15 19:37     ` Shark8
2021-03-16  7:17     ` Randy Brukardt [this message]
2021-03-16  9:26       ` Paul Rubin
2021-03-16  9:53       ` Dmitry A. Kazakov
2021-03-16  9:16     ` Stephen Leake
2021-03-16 11:04       ` Niklas Holsti
2021-03-16 22:49         ` Stephen Leake
2021-03-15 18:37 ` Jeffrey R. Carter
2021-03-15 18:54   ` John McCabe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox