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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,459feef56669b92d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-03 10:52:43 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!elnk-pas-nf1!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread4.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: "continue/next" for "loop" References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <%txpb.5381$qh2.2068@newsread4.news.pas.earthlink.net> Date: Mon, 03 Nov 2003 18:52:43 GMT NNTP-Posting-Host: 63.184.1.194 X-Complaints-To: abuse@earthlink.net X-Trace: newsread4.news.pas.earthlink.net 1067885563 63.184.1.194 (Mon, 03 Nov 2003 10:52:43 PST) NNTP-Posting-Date: Mon, 03 Nov 2003 10:52:43 PST Xref: archiver1.google.com comp.lang.ada:2008 Date: 2003-11-03T18:52:43+00:00 List-Id: Robert I. Eachus wrote: > But I think in the case of loops, there are clearly two specialized > forms of goto that should be considered: > > goto exit; -- exit innermost enclosing loop. > exit loop; -- alternative syntax. ;-) This already exists in Ada; it's syntax is exit; Without a loop name or when part, exit exits the innermost enclosing loop. > and > > goto end; -- skip to start of next loop iteration. > goto loop; > goto begin; This doesn't exist. Ichbiah and others were aware of "continue" in C but chose not to include it in Ada 83. Did they have a good reason? Is the Ada-83 Rationale available on line anywhere? The problem with this discussion is that we don't know what the OP is trying to do; we only know how he is trying to do it, sort of. As pointed out elsewhere, the goto's could be converted to "exit Inner;" and the statements between "end Inner;" and "end Outer;" removed, with no change in behavior, so we don't really even know how the OP is trying to do whatever he is trying to do. If we knew what he was trying to achieve, rather than how he was trying to do it, we might be able to propose an alternative approach that would avoid his problem. Assuming some way to exit Inner and execute the statements between the end of Inner and the end of Outer, we have seen a number of ways to achieve this: goto statements, a Boolean flag, and exceptions. Another way is to use a dummy loop and exit it: Outer : loop Dummy : loop Inner : loop ... if First then ... exit Dummy; end if; ... if Second then ... exit Dummy; end if; ... exit Inner when Third; end Inner; ... exit Dummy; end Dummy; end Outer; -- Jeff Carter "I blow my nose on you." Monty Python & the Holy Grail 03