|
Re: Recursion?
By the way, I didn't mean the C command goto, I was talking about the asm command goto.
In asm the only way of "looping" is with goto's or branches.
I think the idea of goto being bad coding practice comes from BASIC. Programs with large numbers of gotos get incredibly confusing to read, since there really is no flow in the program. The program can just jump to any other point without warning and the reader is left wondering why, especially in BASIC with line numbers and statements like "GOTO 150."
for and while loops help to keep everything structured and easy to follow. Break and continue interrupt that flow, but they made their way into the higher level languages because they are useful and simplify code a lot.
Can you imagine trying to break out of a loop without break? You would need a flag, and all the code after the point you wanted to break from would have to be under an if statement to check to see whether the break flag has been set to true. It could get quite ugly.
Basically, a lot of goto's in a program is probably a bad idea, but they can be useful in certain situations. If you can find a way to do it without goto's that doesn't hurt performance a lot, do it.
|