GOTO is usually evil because it allows you to create unstructured code. Using regular loops, you can easily build good structured code because it is structured.
When you have unstructured code jumping from here to there, you have just discovered the evil emanating from the GOTO instruction. It is almost always better to avoid this. Maybe every 100,000 lines there is a place where the GOTO clause simplifies the LOT, so the code is not evil, but if you are not sure, you should avoid GOTO.
Hope this helps.
EDIT: Well, just to add my own opinion here, there are other instructions that allow you to create unstructured code and that are not considered evil when I think they should be.
For example, returning in the middle of a function is GOTO to the end, so I avoid them and use only one return in each function only at the end.
Other languages, such as Vb.Net (possibly others), allow you to do Exit For, Exit While, breaks, etc., which also unstructure the code, and I think this should be avoided.
Ignacio Soler Garcia Dec 14 '09 at 10:10 2009-12-14 10:10
source share