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=0.8 required=3.0 tests=BAYES_50 autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a37:6491:: with SMTP id y139mr26444030qkb.483.1615832405391; Mon, 15 Mar 2021 11:20:05 -0700 (PDT) X-Received: by 2002:a25:9303:: with SMTP id f3mr1487389ybo.165.1615832405230; Mon, 15 Mar 2021 11:20:05 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!goblin1!goblin.stu.neva.ru!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 15 Mar 2021 11:20:05 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=80.229.20.55; posting-account=WsVe0AoAAABheGmBjlLgPWhgIw6kxcL6 NNTP-Posting-Host: 80.229.20.55 References: <38356aa9-b8b0-4e0b-a490-99e7b239d0b1n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7c69dbf3-b5ef-447c-985f-379747278484n@googlegroups.com> Subject: Re: Ada and "early return" - opinion/practice question From: John McCabe Injection-Date: Mon, 15 Mar 2021 18:20:05 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:61533 List-Id: On Monday, 15 March 2021 at 18:12:38 UTC, Shark8 wrote: > On Monday, March 15, 2021 at 10:46:39 AM UTC-6, wrote:=20 > > I hope this isn't a FAQ (it's hard to find relevant articles) but can s= omeone guide me on the 'normal' treatment in Ada style of what appears to b= e referred to (by C/C++ programmers) as early-return. > Exceptions, typically.=20 <..snip..> Thanks for that. > > I've probably mentioned this before, but it's a long time since I used = Ada in anger and I don't remember seeing stuff like that when I did use Ada= a lot; does anyone write stuff like that in Ada?=20 > >=20 > > When I first learnt to program properly it was using Pascal with, as I = remember it, only one return from a function being allowed, > Your memory is correct... for Pascal.=20 > Ada has always allowed multiple return statements in a subprogram, with a= "return" in a procedure acting as a "jump to the end, do clean-up". Yes; I knew Ada could, but I checked on the Pascal stuff the other day. Thi= ngs have changed a bit since then (it was, after all, 1983!) but I became q= uite indoctrinated by that style and it's been hard to shift away from ;-) > > so over the years I've mostly looked at positive conditions and indente= d stuff, pulling the stuff in the middle out into its own procedure or func= tion where appropriate, but you see so many people defending this style in = C/C++ that I wonder whether it really is defensible? > No, it's not defensible... at least IMO. :-)