Re: Good Use of GOTO
- Posted by c.k.lester <euphoric at ckles??r.com> Jun 06, 2008
- 859 views
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. 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.