12.04.2013, 20:48
Quote:
Ah.
As far as answering the speed questions, it depends how they are compiled, which I know virtually nothing about. You could write up some speeds tests, but I doubt one would be significantly faster than the others. Code-wise, goto statements are very poor practice. Again, you can read up why on the thousands of cases documented. |
It makes your code look like it could've been written better, and it looks bad on the eye.
However, from looking on my example again, I don't see anything too messy or painful to understand, just a simple jump statement.
Quote:
I recall reading that we actually have loops to avoid having to use goto. Although, there should be nothing explicitly wrong with it in many coding languages, it is considered bad practice. When you use goto, it is an indication that your code could probably be built up in a better fashion (so it is less confusing). It is up to you to run the speed tests, also see what the assembly output looks like (compile with -a) and see the differences. Short version - structured programming is here to avoid goto. |
But then again, I don't see anything confusing in the basic example that I wrote that is hard to understand.
It is used in a simple loop, with only one condition, like most of the loops scripters around here write.
A loop can be badly written regardless of it consists goto statements or do-while loops, it is all up to the organization the scripter dedicates to his coding.
Why was this moved here?
This topic is a discussion and not a help request.