Label problems
BlitzMax Forums/BlitzMax Beginners Area/Label problems
| ||
I have a label in my game and I want to do a goto. When I compile I get "Compile Error, Labels must appear before a loop or DefData statement", yet the example for "Goto" (in the docs) compiles fine. What is going on? Thanks |
| ||
Wasn't there a label restriction @ strict mode orso? |
| ||
I'm sure I read that Strict disables Goto as well. There must be a better way than using a Goto? |
| ||
yeah there probably is, I was feeling lazy. OK so it's cos I've got strict on, thanks. |
| ||
GoTo is slugish programming thus disabled in Strict. If you needed it to exit nested loops, you can label the loops and exit several nested loops by exit labelname as well as continue labelname |
| ||
It's not slugish programming. It just has the potential to mess with scope and screw up the state of the stack, causing random crashes and making it near impossible to maintain code. Good for job security tho'. |
| ||
Goto wasn't sluggish when the Spectrum was invented, anyway ... it was just the one thing, Goto Shutdown, called in my main loop so that the shutdown proc could be run. I just made it into a function in the end, so no worries. Actually, some people even decry the use of Return to exit prematurely from functions, thinking everything should be indented/nested hugely even if it actually makes the code harder to understand... |
| ||
Goto wasn't sluggish when the Spectrum was invented Compilers wheren't as advanced, memory wasn't as abundant, and programs wheren't as complex at the time. Actually, some people even decry the use of Return to exit prematurely from functions Yeah. Well there's no way to guard against that kind of stupidity. |
| ||
Goto is a relic from the days when source code still had line numbers. And I'm old enough to still remember that :) |