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,7596cfba54ad3207 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-05 15:25:32 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn1feed!wn4feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc02.POSTED!not-for-mail Message-ID: <3D261D77.1060707@attbi.com> From: "Robert I. Eachus" Organization: Eachus Associates User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) Gecko/20020314 Netscape6/6.2.2 X-Accept-Language: en,pdf MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Trivial Ada question References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.61.239.24 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc02 1025907932 24.61.239.24 (Fri, 05 Jul 2002 22:25:32 GMT) NNTP-Posting-Date: Fri, 05 Jul 2002 22:25:32 GMT Date: Fri, 05 Jul 2002 22:25:32 GMT Xref: archiver1.google.com comp.lang.ada:26891 Date: 2002-07-05T22:25:32+00:00 List-Id: Grein, Christoph wrote: > This was a joke, wasn't it? Is this really better than a simle and innocent and > nearby goto? A one-time 'loop' enclosing another work loop... ... > I have to confess that I have not needed a goto in so many years, but the goto > solution is one of the simplest solutions of all those presented. I totally agree. However, there is a "reasonable" nested loop version... INCREMENT: loop for I in A'Range loop exit INCREMENT when condition (A (I)); end loop; N := N + 1; exit INCREMENT; end loop; Again the compiler has a chance to generate the correct simple code. But we still haven't done anything about the fact that the inner loop has two exits that need to be tested. (The outer loop has a single exit and doesn't add any real complexity to the program flow.) Which is why this discussion sort of bothers me. The underlying complexity of the algorithm can be hidden, but who are you hiding it from? It had better not be the test team. And that is why I like the goto here. It screams to the testers (and other readers) that the water is deep here. You have to insert a mental bookmark and read the two paths separately. In fact, the I would probably stick in a comment: -- This loop must have two exits. It is the "must have" that is key, not how it is implemented.