Only bad usage of goto is to create loops with goto _instead_ of do/while,and also goto into loops from outside.
That known rule are frequently misinterpreted as "no goto!" rule,because,as someone pointed out,theoretically,goto are not needed.But even puristic languages by Wirth all have goto. Because it's useful thing and may improve readability.
If you REALLY need to goto upward,do
label1:{
....
somewhere there goto are placed.
....
}//label1^
Just look downward to find to where you are going
I frequently use break and sometimes use goto,but my goto's really rarely points upward in code. So,to find to where flow are going you just need to look down the code. And i never use continue because i think continue is not necessary.
Instead of
for(something){blablabla1...if(a) continue; blablabla2}
i'm usually just using
for(something){blablabla1...if(!a){ blablabla2}}
Goto pointing downward are not a bad thing at all.
Also,i'm remembering one code that was most natural using loops made with goto :
loop1start:
Do Thing 1;
loop2start
Do Thing 2;
if(condition1) goto loop1start;
Do Thing 3
if(condition2) goto loop2start;
Think about it.I have 2 loops that shares same code "Do Thing 2".It was natural for that algorithm.Any other thing used instead of goto would be hideous.Duplicating thing2 are hideous too.
And,exceptions.
Exceptions shouldn't be used to exit loops..Each tool have it's use. Remember that from theoretical point of view exception is a only form of goto! .
In any case,if you code complicated things without using goto and break ,you will end up having a lot of boolean flags instead.It will make your program MUCH less readable.
Example:
bool breakflag=0;do{ ....... ....... do{ ....... ....... If(!(BreakFlag = mat[i,j]==0)){ ....... ....... } }while((j<i)&&(!BreakFlag)); if(!BreakFlag){ ..... ..... };}while ((i>0)&&(!BreakFlag));versusdo{ ....... ....... do{ ....... ....... If(mat[i,j]==0)goto loopsexit1; ....... ....... }while(j<i); ..... .....}while (i>0);loopsexit1:
And imagine that there are four loops and seven reasons to exit and you will see what some programmers have to deal with.How you want to do it without goto? Does it increase quality of code?Or any complicated code are low-quality?
And also,there are non-recursive parsers like ones produced by Lex.
Imagine doing similar things without goto...that would be a hell.