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:ad4:510d:: with SMTP id g13mr5995192qvp.3.1615826798049; Mon, 15 Mar 2021 09:46:38 -0700 (PDT) X-Received: by 2002:a25:d843:: with SMTP id p64mr742741ybg.339.1615826797806; Mon, 15 Mar 2021 09:46:37 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.mixmin.net!aioe.org!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!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 09:46:37 -0700 (PDT) Injection-Info: google-groups.googlegroups.com; posting-host=80.229.20.55; posting-account=WsVe0AoAAABheGmBjlLgPWhgIw6kxcL6 NNTP-Posting-Host: 80.229.20.55 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <38356aa9-b8b0-4e0b-a490-99e7b239d0b1n@googlegroups.com> Subject: Ada and "early return" - opinion/practice question From: John McCabe Injection-Date: Mon, 15 Mar 2021 16:46:38 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:61524 List-Id: I hope this isn't a FAQ (it's hard to find relevant articles) but can someo= ne guide me on the 'normal' treatment in Ada style of what appears to be re= ferred to (by C/C++ programmers) as early-return. For example, you have a C++ function (pseudo code sort of thing): fn() { if () { return ; } if () { return ; } if () { return ; } // Only get here if everything's good... return ; } 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 l= ot; does anyone write stuff like that in Ada? When I first learnt to program properly it was using Pascal with, as I reme= mber it, only one return from a function being allowed, so over the years I= 've mostly looked at positive conditions and indented stuff, pulling the st= uff in the middle out into its own procedure or function where appropriate,= but you see so many people defending this style in C/C++ that I wonder whe= ther it really is defensible? Hope this is ok to ask! John