From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.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: stopping a loop iteration without exiting it Date: Thu, 4 Jan 2018 19:31:17 -0600 Organization: JSA Research & Innovation Message-ID: References: <81971548-23c9-4927-a6a8-6f0f1dba896b@googlegroups.com> Injection-Date: Fri, 5 Jan 2018 01:31:18 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="20405"; 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; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:49761 Date: 2018-01-04T19:31:17-06:00 List-Id: "Niklas Holsti" wrote in message news:fb680nFc4gpU1@mid.individual.net... > On 18-01-04 01:17 , Robert A Duff wrote: >> "Randy Brukardt" writes: >> >>> A "goto" is *not* stupid in this case. >> >> I agree. There are (rare) cases in Ada when "goto" is the right >> solution, and nested "continue" can be one of them. > > But many coding rules frown on "goto" (with good reason, IMO). If > "continue" is implemented with "goto", either the code-rule-checking tools > will flag these "gotos" as violations, or the tools must be taught to > tolerate "gotos" when they are used for "continue". There is nothing the Standard can do about bad programming management. ;-) Coding standards that blindly ban features force programs into convuluted structures. Which defeat the purpose of the coding standard in the first place. > IMO, if there is a frequent need for a "continue" construct in Ada > programming, it should just be added to the language, even if this seems > like shameful imitation of some other, more popular languages. It's not a frequent need, it's just a non-zero need. I find I end up up writing such a goto (very roughly) once a year. But a good number of them aren't strict continues; there's often something at the bottom of the loop after the label. > That said, I don't remember ever having a need for a "continue" in my Ada > programming, but perhaps this depends on one's design style and favourite > coding idioms. > >> In fact, the goto is BETTER than the continue statement, because the >> place where it's jumping to is marked with a label, .. > > If "continue" were added to Ada, of course it should have an optional > loop-name to mark the loop being continued, as for the current "exit": > > exit Search_Loop when ...; > > continue Search_Loop when ...; I think you miss the point: the fact that there is a goto to the end of the loop is marked by a label in this (the "continue") case. "Continue" is NOT the usual case (it is rare enough that we decided not to add it because it would need a new keyword and inevitably break existing code using the label "Continue"), so the presence of the label at the end keys the reader that you can get there in other ways then just dropping out of the if statement that probably preceeds the "end loop". That's what Bob meant by saying that it is "better". (The sort of loop that needs a "continue" is likely to be very long.) This is likely the same reason that Ada 83 didn't allow goto to a loop name (when one sees a loop name, one ignores it unless you are tracing exits). Randy.