comp.lang.ada
 help / color / mirror / Atom feed
From: yeung@reed.edu (Woodrow Yeung)
Subject: Re: GOTO considered necessary
Date: 1997/06/17
Date: 1997-06-17T00:00:00+00:00	[thread overview]
Message-ID: <yeung-ya02408000R1706971500240001@news.apple.com> (raw)
In-Reply-To: dewar.865693869@merv


In article <dewar.865693869@merv>, 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
>        ...
>        <<Continue>>
>     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




  reply	other threads:[~1997-06-17  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-06  0:00 GOTO considered necessary Samuel Mize
1997-06-06  0:00 ` Michel Gauthier
1997-06-07  0:00 ` Robert Dewar
1997-06-17  0:00   ` Woodrow Yeung [this message]
1997-06-20  0:00     ` Robert Dewar
1997-07-09  0:00       ` Woodrow Yeung
1997-06-23  0:00     ` Adam Beneschan
1997-06-07  0:00 ` Michael F Brenner
1997-06-08  0:00   ` Robert Dewar
1997-06-17  0:00     ` GOTO considered necessary (FSAs) Nick Roberts
1997-06-09  0:00 ` GOTO considered necessary Anonymous
1997-06-09  0:00 ` Wolfgang Gellerich
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox