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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,14f7200925acb579 X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: No Go To's Forever! Date: 2000/03/22 Message-ID: #1/1 X-Deja-AN: 600994808 References: <8baqlu$3qp$1@nnrp1.deja.com> X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 953755998 206.170.2.160 (Wed, 22 Mar 2000 12:13:18 PST) Organization: SBC Internet Services NNTP-Posting-Date: Wed, 22 Mar 2000 12:13:18 PST Newsgroups: comp.lang.ada Date: 2000-03-22T00:00:00+00:00 List-Id: > Of course you could argue that it is easier to find your refined > superior form from my syntactic expression with nested loops > than from the original with a goto, and that would be an > interesting argument to make. I'll make that argument. "while" etc make the flow clearer, and thus easier to understand and improve, than goto's. > <> > for J in 1 .. N - 1 loop > if D (J) < D (J + 1) then > Swap (D (J), D (J + 1)); > goto Do_It_Again; > end if; > end loop; I personally find this clearer, even if a tad longer: loop J := D'first; while J < D'last and then D(J) >= D(J+1) loop J := J+1; end loop; exit when J >= D'last; Swap (D (J), D (J + 1)); end loop; > After all the little example here that was given (the blanks > eater with the goto) is perfectly well structured (single > entry-single exit, well formed loops etc, just not very clear! Actually, it had two different entrances: one at the top just before the initial lookup, and another, which presumably should never be used, at the label just after that lookup. One could imagine a program with a typo where a "goto starter" was mis-written as "goto start". The result might be nasty, the compiler not help, and that kind of typo is notoriously hard to spot.