The posted code is precisely the sort of code Edsger Dijkstra was referring to in his famous letter to CACM titled "GOTO Considered Harmful." It's what we used to refer to as "spaghetti code." In this example it's on a small scale, but spaghetti code nevertheless. The stuff as dreams (bad ones) are made on.
When I started programming, that's pretty much the way all code was written. The available languages gave you little choice.
I'm not averse to using goto in code, especially if you're stuck with a primitive language like assembler, FORTRAN IV, or C (I've used goto in all of those). Even in C, the use of goto should really be limited to forward jumps for error paths (to effectively unwind the stack) and not as a general looping control construct as seen here.
Modern languages such as C++ have no need for goto at all. If you structure your logic correctly your code will be far far easier to read, maintain, extend, and explain all without a hint of pasta.
Show differencesHistory of post edits
#1Bregma
Posted 11 November 2012 - 07:59 PM
The posted code is precisely the sort of code Edsger Dijkstra was referring to in his famous letter to CACM titled "GOTO Considered Harmful." It's what we used to refer to as "spadhetti code." In this example it's on a small scale, but spaghetti code nevertheless. The stuff as dreams (bad ones) are made on.
When I started programming, that's pretty much the way all code was written. The available languages gave you little choice.
I'm not averse to using goto in code, especially if you're stuck with a primitive language like assembler, FORTRAN IV, or C (I've used goto in all of those). Even in C, the use of goto should really be limited to forward jumps for error paths (to effectively unwind the stack) and not as a general looping control construct as seen here.
Modern languages such as C++ have no need for goto at all. If you structure your logic correctly your code will be far far easier to read, maintain, extend, and explain all without a hint of pasta.
When I started programming, that's pretty much the way all code was written. The available languages gave you little choice.
I'm not averse to using goto in code, especially if you're stuck with a primitive language like assembler, FORTRAN IV, or C (I've used goto in all of those). Even in C, the use of goto should really be limited to forward jumps for error paths (to effectively unwind the stack) and not as a general looping control construct as seen here.
Modern languages such as C++ have no need for goto at all. If you structure your logic correctly your code will be far far easier to read, maintain, extend, and explain all without a hint of pasta.