comp.lang.ada
 help / color / mirror / Atom feed
From: adam@irvine.com (Adam Beneschan)
Subject: Re: GOTO considered necessary
Date: 1997/06/23
Date: 1997-06-23T00:00:00+00:00	[thread overview]
Message-ID: <5ombp9$c3a$1@krusty.irvine.com> (raw)
In-Reply-To: yeung-ya02408000R1706971500240001@news.apple.com


yeung@reed.edu (Woodrow Yeung) writes:
 >
 >> 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. . . .

I have to disagree.  When I used to program in C, I made a rule for
myself not to use the "continue" statement.  The reason: When I did
use it in a loop, it worked fine, but then I'd find I had to make a
modification that required that some extra actions to be taken at the
end of each loop, before going to the next iteration.  So I'd add
those changes just before the closing }.  All of a sudden, "continue"
no longer worked; if I had any continue's up in the remainder of the
loop code, I would have to search for them so that I could replace
them with something else, and if I forgot, oops, I just put a bug into
the program.  

At least if you have a goto-label construct:

    while ..... loop
       ...
       <<Continue>>
    end loop;

Now, when you have to add something just before "end loop", at least
the presence of a label alerts you to the fact that something might be
jumping there in order to perform a "continue"; now, you have to
decide whether to add your code after or before the label.  But you're
less likely to make a modification that would screw things up.  At
least, that's my experience.

Sure, one could come up with a case where "break" (or "exit", in Ada)
has the same problem, but my experience is that problems like this
don't occur--or rarely occur--with exit constructs; while they seem to
be more frequent with "continue".  I don't know why "continue" should
be considered cleaner than an appropriate GOTO construct; I don't know
what definition of cleanliness would make this so, except for one that
proclaims that GOTO's are inherently unclean just because they are.  I
had to get over this attitude when programming in COBOL 66.  [I think
I got the language version right this time.  :)]

(BTW, I'm not likely to use *either* construct: boolean variables seem
to work better for me.)

                                -- Adam




  parent reply	other threads:[~1997-06-23  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 ` Michael F Brenner
1997-06-08  0:00   ` Robert Dewar
1997-06-17  0:00     ` GOTO considered necessary (FSAs) Nick Roberts
1997-06-07  0:00 ` GOTO considered necessary Robert Dewar
1997-06-17  0:00   ` Woodrow Yeung
1997-06-20  0:00     ` Robert Dewar
1997-07-09  0:00       ` Woodrow Yeung
1997-06-23  0:00     ` Adam Beneschan [this message]
1997-06-09  0:00 ` Wolfgang Gellerich
1997-06-09  0:00 ` Anonymous
replies disabled

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