Re: Good Use of GOTO

new topic     » goto parent     » topic index » view thread      » older message » newer message

c.k.lester wrote:
> 
> Michael J. Sabal wrote:
> > c.k.lester wrote:
> > >    continue, exit, retry, etc...
> > I thought the whole point of introducing GOTO was so as not to litter the 
> > language with all these extra keywords.  I vote to keep GOTO and get rid
> > of all the other words (except exit, for legacy's sake).
> 
> GOTO is a poor substitute for these other words.
> 
> for t=1 to 10 next
>   if a then
>     continue
>   else
>     -- code
>   end if
> end for
> 
> In the above very simple example, which nobody should ever use but it is
> analogous to something more complicated, the continue tells the interpreter
> to resume the loop... meaning, it knows to increment t then goto the top and
> resume execution.

Continue where? Now when i see a for loop, i haveto be concerned that somewhere,
someone may have put in a "continue", or perhaps a "retry", and come back up to
the top of the loop in a most UN-NATURAL way, making the loop var either what it
should be, or something else! Or WORSE, and "entry" keyword! Now i haveto scan
for those words when reading, always in the back of my head, that they will cause
some program flow that is not within the promised for-next-endfor loop. And don't
get me started on "exit" which works differently for procedures, while-loops, and
for-loops! The difficulty in maintaining this garbage is going to be
astronomical, and i want to know who is going to keep up orphaned code like that,
because it certainly won't be me!
 
> How would you use GOTO there?
> 
> for t=1 to 10 next
>   if a then
>     goto...?
>   else
>     -- code
>   end if
> end for
> 
> In all the cases of continue, retry, exit, the interpreter and programmer
> are constantly aware of code structure and flow. With GOTO, you have to
> resort to contortions to do the same thing that these simple words allow.
>
> In the example above, no matter where you GOTO, your loop var will not
> increment... without extra [cumbersome] code.

OMG, you mean like:

t += 1 
or 
t -= 1

How horrific! The sight of such makes me light headed, i swear. If i could only
tell you how many times in the past i have had to inc a var when i wanted it
inc'd, and those vars had no clue of my intentions unless i typed it out in plain
text for all the freaking world to see, it just breaks my heart to see new
programmers making explicit code, or :labels, or continue(+2), or retries(-1),
or,,, or such, and not hiding the changes they have made to loop vars in using
new keywords. Thanks for pointing this out, CK!

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu