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,a7f223906eb859a X-Google-Attributes: gid103376,public From: yeung@reed.edu (Woodrow Yeung) Subject: Re: GOTO considered necessary Date: 1997/06/17 Message-ID: #1/1 X-Deja-AN: 249163001 References: <5n977i$2cmc$1@prime.imagin.net> Organization: Reed College Newsgroups: comp.lang.ada Date: 1997-06-17T00:00:00+00:00 List-Id: In article , dewar@merv.cs.nyu.edu (Robert Dewar) wrote: > There are many places where a goto is the natural and clearest way of doing > things. > THere are many obvious examples, one of the most familiar is to provide > a continue facility for loops > > while ..... loop > ... > <> > end loop; Oh dear, I have to disagree with this on two levels. It's far cleaner to have a continue control structure than using a goto to implement it. One of the classic example of using gotos is jumping out of nested loops, but labeled loops are much better. Goto's should not be used in a HLL to implement structured control flow, especially in a language as rich as Ada. On the other level, I find the continue facility to be of marginal utility and counterproductive. It would be a pity to let a continue statement destroy the principle of maintaining single entry and exit in a control structure. (I'm more tolerate of breaking out of loops.) It doesn't buy you anything compared to just reorganizing your loop body with if's, and continues sure make maintenance a nightmare. If one argues that a continue makes the loop clearer compared to guarding with an if then I have to say that the body of the loop has gotten to be too convoluted. Parts could be implemented in routines so you don't get a really gross looking if then else block. A good compiler should be able to inline the routine so you don't loose any efficiency. Goto's should not be used to fake continues. Woody Yeung yeung@reed.edu