Goto
- Posted by Robert Craig <rds at ATTCANADA.NET> Nov 15, 1999
- 420 views
Since some people think I should come out of hiding and voice an opinion on language design proposals, here's my current thinking about goto. 1. completely general goto, including jumps between routines: 0% chance 2. goto within a routine: 0.01% chance 3. specialized goto to break out of nested loops: 1% chance I'm not religiously opposed to goto's. There are some goto's coded into the C source of the interpreter, and at one point in the early days I even had one of the "between routines" gotos that are possible in C using setjmp()/longjmp(). It proved to be nightmarishly hard to understand and maintain so I took it out. I agree that a specialized goto (or special "exit") to get out of a nested loop is probably less clumsy than setting up artificial state variables. I just don't think that this occurs often enough, or causes enough pain to warrant a new language feature, such as labelled statements and a special kind of exit. The normal sort of gotos, that let you jump around within a routine are like cigarettes. One or two, once in a while, will not harm you. The trouble is they become addictive. If you never start using them, you will never have a craving for one. When I had to maintain code written by someone else, the sight of a heavily goto'd section of code would really be discouraging. The guy who wrote the goto's probably had some idea of what the control-flow was supposed to be, but I had to struggle to get the same picture into my head. Standard control-flow statements, like for..end for, if-elsif-else etc are much easier to digest and reason about. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com