QUOTE(Tom9729 @ 2 Aug, 2008 - 01:08 PM)

Usually the people who say "don't use goto statements" can't offer a reasonable reason to back it up.
Goto's do not lead to spaghetti code. Careless programming leads to spaghetti code. Suggesting that some language statement is to blame is ridiculous.

Just wanted to make a few statements about this and the thread at large...
1) Well several reasons can be made not to use goto statements... check out Code Complete 2 by Steve McConnell page 398. He lists several including a reference to Dijkstra and his paper in March 1968 to the Communications of the ACM called "Go To Statement Considered Harmful" where Dijkstra himself lists problems with goto statements.
2) While McConnell does state disadvantages he does state some advantages too. However his end conclusion is that 99 out of 100 goto situations can be made more efficient and easier by using a goto-less approach, but does say that there are situations where a goto just might be of use. He said and I quote:
"In the remaining one case out of 100 in which a goto is a legitimate solution to the problem, document it clearly and use it. If you have your rain boots on, its not worth walking around the block to avoid a mud puddle. But keep your mind open to goto-less approaches suggestd by other programmers. They might see something you don't." --
Code Complete 2, Steve McConnell, page 407This does back up statements Nick has made but it also flies in the face of the idea that goto is something that should be used regularly.
3) Goto statements are often put in by lazy and careless (sometimes lacking experience) programmers. Thus they tend to abuse it as a matter of bad habit and that bad habit and bad use of goto tends to lean towards bad code organization and results in spaghetti code. Goto isn't solely responsible for spaghetti code, but it certainly helps.
4) I love analyzing computing languages themselves and have seen endless lines of code and very very rarely do I ever see a goto. The ones I do see could probably have been avoided.
5) Lastly, if you ever find yourself making tons of nested if statements in an attempt to get around a goto, this just means you are not using other design techniques out there that can reduce this problem.
This post has been edited by Martyr2: 3 Aug, 2008 - 12:38 PM