-
my tuppence
on the C programming correspondance course i did, i received half- marks for using a goto !!! i thouight this was well extreme and complained. they said it demonstrated unstructured programming and wouldn't change the marks.
the course notes said " goto can be used to create quick routines, but its use can never be considered necessary "
"goto statement implies bad programming skills and lack of structered design. however you may find goto is an acceptable method of bypassing a particular section of code rather than designing some convoluted logical test to avoid its use"
also said "goto has inherent problems".
so i don't think they were especially sure about it !! but i think all these quotes are fair comment. (from my own limited experience)
-
Well the way I see it is that it is in the standard and thats for a reason. I also think that if you really know what you are doing(I am not) you probably will have rare cases where goto will do good. But no one on this board(except 0ne or two) should use it. I have never seen a case where I have to use it or where it will be clearer to use it. But I think it is wrong to say that it always is 100% wrong o use goto. Goto have a justified place in the C language.
-
I have a read a copy of the reports released the ANSI X3J11 responsible for standardizing C.
It said there that goto was placed there just for convention, since C is not very far from Assembly. The committee also recommended that its used be avoided or minimized. Otherwise, the block structure of functions will no longer be important since goto will and can jump to any line in the code considered.
In Assembly maybe, goto is important for performance. But we are talking C and C++ here and you rarely see complex software projects written in largely in Assembly.
Lastly, C's elegance has mainly been appreciated because it promotes readability and modularity (thanks to the gotoless programming philisophy.)