goto
BlitzMax Forums/BlitzMax Programming/goto That's right. And I bet 99.99% of the users here would not advice to use goto anyway.
Not sure what you're asking. Goto isn't available in SuperStrict mode although the documentation doesn't give much info about it.
If you explain what the special case is people might have some suggestions.
If you explain what the special case is people might have some suggestions.
but I have one small area where this would be the perfect solution
Then your design is flawed ;-)
Use superstrict while you design your code and then switch it off when you compile your final version?
Goto is not allowed in SuperStrict mode. There's nothing wrong with it if that's how you like to program.
Goto is not allowed in SuperStrict mode. There's nothing wrong with it if that's how you like to program.
It's all good...it was easy enough to alter this particular function to so it would flow like I needed. I was really looking for a (lazy) way of doing it when I came across the goto command in the documentation and thought: hey, why not give it try?
But this doesn't change the fact that the example posted in the documentation is fundamentally wrong, which was really more the point to my original post.
But this doesn't change the fact that the example posted in the documentation is fundamentally wrong, which was really more the point to my original post.
But this doesn't change the fact that the example posted in the documentation is fundamentally wrong, which was really more the point to my original post.
What is wrong with it though? The example for Goto works fine it's just that Superstrict doesn't allow it and is undocumented.
Unless I am missing something.
What is wrong with it though? The example for Goto works fine it's just that Superstrict doesn't allow it and is undocumented.
Unless I am missing something.
Unless I am missing something.
Actually, it's perfectly well documented. Here's what the docs say about goto in BASIC compatibility:
The Goto command is supported, but only in non-strict mode.
Apparently you are missing something.
In the Documentation there is an important bit of undocumented information.
This one glaring problem with BlitzMax is why so many people often return to ask fundamental questions.
In the Documentation there is an important bit of undocumented information.
This one glaring problem with BlitzMax is why so many people often return to ask fundamental questions.
ah, yes, well, we try not to talk about the documentation around here...
@Otus: I did eventually find that bit of documentation. There are two sections called "Basic Compatibility", one under Language and one under Modules/Basic. A simple fix for this would have been to put that info with the goto documentation itself; or better yet, remove the command altogether as it seems to be so reviled and doesn't have any usefulness.
@Brucey: agreed.
@Brucey: agreed.
In the Documentation there is an important bit of undocumented information.
How can there be undocumented information in the documentation? It'd surely be documented if it was in there.Anyway, don't know why everybody's ready to burn people at the stake for using goto. If it can solve a problem and save you hours of work, use it. Who cares?
10 CLS
20 PRINT "JIM IS COOL!";
30 GOTO 20
>RUN
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
*Break in Line 20
Ready
>_
My first program **ever** written back in 1980. Should give you an idea of how obsolete GoTo's are.
20 PRINT "JIM IS COOL!";
30 GOTO 20
>RUN
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!JIM IS COOL!
*Break in Line 20
Ready
>_
My first program **ever** written back in 1980. Should give you an idea of how obsolete GoTo's are.
Then your design is flawed ;-)
I don't use goto for the fear that i'll just cause myself infinite loop glitches, other then that if you're careful I don't see what the problem is with it..in fact I could see it saving conditional statements and saving many lines of code in many cases. ?
Using Goto isn't lazy. I'm lazy, cos I don't want my code to break in wierd ways, nor do I want it to be impossible to read/debug 2 years from now.
If you value your sanity, don't use Goto and always use SuperStrict.
[Use it if you want, but don't come running to me if your clients/users break your legs.]
If you value your sanity, don't use Goto and always use SuperStrict.
[Use it if you want, but don't come running to me if your clients/users break your legs.]
I like Goto.
Seriously goto is a travesty of a command these days. I grew up programming on the old 8 bit micros with the flawed basic of the Vic 20 and the C64 and knew no better.
Sure, that was how things were programmed back then but it was an absolute pig trying to get myself out of the habbit of programming in such a p1ss poor way when modern languages evolved the development language so much.
Hell, it was just as hard trying to adapt to working without line numbers for the first year or so when I came back to programming after many years away. I do consider goto to be lazy programming now and any program can be written without having to refer to it.
Case in point is "Jim is Cool!" program further up. I used to do the same thing on the old display computers in Debenhams after school when I was a kid. It's a classic example of a quick and dirty bit of code to get a result.
That's not much longer to type but does the same thing and even has an exit point built in.
Don't know why I'm so anti-Goto but it's probably because I used it along with Gosub for so long that it became almost as addictive as Lager. How many times I would scan through a listing wondering why I got an "undefined function error" or similar and spent ages trying to track down the bug. Always it was because I'd kept gosubing to a subroutine and forgetting to return from it or because my program flow had strayed into a routine and was trying to return from a routine that hadn't been branched to in the first place.
It's easilly argued that use of goto/gosub could be justified if used properly but I don't think it has a place today for practicalities sake when you can drop in neat functions which can share or hold exclusive variable definitions or even have methods within types that can all be dropped at the end of a program listing out of the way once working correctly so you can forget about them because they won't get called accidentally etc.
And my favourite argument is SuperStrict not liking it. Proves that I'm not the only one who thinks it's obsolete - Mark Sibly obviously doesn't like it either.
Sure, that was how things were programmed back then but it was an absolute pig trying to get myself out of the habbit of programming in such a p1ss poor way when modern languages evolved the development language so much.
Hell, it was just as hard trying to adapt to working without line numbers for the first year or so when I came back to programming after many years away. I do consider goto to be lazy programming now and any program can be written without having to refer to it.
Case in point is "Jim is Cool!" program further up. I used to do the same thing on the old display computers in Debenhams after school when I was a kid. It's a classic example of a quick and dirty bit of code to get a result.
SuperStrict Repeat Print "Tony is Cool!" Until KeyHit(Key_Escape)
That's not much longer to type but does the same thing and even has an exit point built in.
Don't know why I'm so anti-Goto but it's probably because I used it along with Gosub for so long that it became almost as addictive as Lager. How many times I would scan through a listing wondering why I got an "undefined function error" or similar and spent ages trying to track down the bug. Always it was because I'd kept gosubing to a subroutine and forgetting to return from it or because my program flow had strayed into a routine and was trying to return from a routine that hadn't been branched to in the first place.
It's easilly argued that use of goto/gosub could be justified if used properly but I don't think it has a place today for practicalities sake when you can drop in neat functions which can share or hold exclusive variable definitions or even have methods within types that can all be dropped at the end of a program listing out of the way once working correctly so you can forget about them because they won't get called accidentally etc.
And my favourite argument is SuperStrict not liking it. Proves that I'm not the only one who thinks it's obsolete - Mark Sibly obviously doesn't like it either.
Oh ho, not this debacle again.
Gotos are perfectly fine to use, and they are NOT evil!
However, if you ONLY use gotos to control flow in your program YOU are evil ;)
EDIT:
Not necessarily, SuperStrict is there to catch common user errors, Goto being one of them.
Gotos are perfectly fine to use, and they are NOT evil!
However, if you ONLY use gotos to control flow in your program YOU are evil ;)
EDIT:
SuperStrict not liking it. Proves that I'm not the only one who thinks it's obsolete - Mark Sibly obviously doesn't like it either.
Not necessarily, SuperStrict is there to catch common user errors, Goto being one of them.
Oh ho, not this debacle again.
Gotos are perfectly fine to use, and they are NOT evil!
However, if you ONLY use gotos to control flow in your program YOU are evil ;)
*applause*Gotos are perfectly fine to use, and they are NOT evil!
However, if you ONLY use gotos to control flow in your program YOU are evil ;)
As a side-note, Idigicon's "Derby Day" was written entirely using Gosub/Return. Not a single function anywhere.
@Tachyon
Sorry but I was taking you word-for-word :
I agree it would have been nice and very easy to have it documented in the Goto entry. I've given up on reporting any documentation or feature stuff though.
Apparently you are missing something.
Sorry but I was taking you word-for-word :
the example posted in the documentation is fundamentally wrong
I agree it would have been nice and very easy to have it documented in the Goto entry. I've given up on reporting any documentation or feature stuff though.
Goto is actually used alot in low level coding, I don't understand why any serious developer frowns on it's use. I used to write JMP() tables back in the day that did some cool stuff. ;)
Idigicon's "Derby Day" was written entirely using Gosub/Return. Not a single function anywhere.
Surly we have to concider gosub return as a function call, just with all viables as global.
That is pre "sub" or "function" isnt gosub/return HOW we used to sub program our programs?
ANyway I dont see whats wrong in letting a programmer have (what is in effect) a jump command. Yes its over use makes code a nightmare, BUT somtimes it offers elegant solutions.
I think the last time I actually used Goto in anger was in a text-on;y adventure game I wrote on the Commodore 64 in C= BASIC back in about 1986. I used it in a jump table for displaying the locations IIRC.
I don't think I've actually needed it since...
I don't think I've actually needed it since...
SuperStrict not liking it. Proves that I'm not the only one who thinks it's obsolete - Mark Sibly obviously doesn't like it either.
ROFL! You kidding? Sibly doesn't even use good coding practices, he coded all the modules in Strict mode (the only real tickle I have with him atm).Now I'm sure someone will bring up SuperStrict wasn't around when he coded them all.. but that doesn't mean they shouldn't be recoded.
he coded all the modules in Strict mode (the only real tickle I have with him atm).
So? The only difference between Strict and SuperStrict is cosmetic. I code in Strict. Being as most of my variables are Ints, it gets a pain having to write it all the time. Goto doesn't work in Strict mode either.
I don't use goto for the fear that i'll just cause myself infinite loop glitches
Infinite loops can be caused by recursive function calling, and plain old Repeat/Until and While/Wend loops. Do other languages have a goto command? If not, it may be practical to learn to code without goto so that moving over to another language is easier.
This won't compile in SuperStrict mode.
Lol, never mind superstrict, you're lucky a vitual MEGA-strict dominatrix doesnt pop out of cyberspace and chase you round the house in your underpants for even considering using it :D
-Just kiddin- they can be handy occasionally if on a very small and local scale, but i try not to use them at all myself. It doesnt surprise me it doesnt work with stricts as there is no structure to them and are pure legacy.
Do other languages have a goto command?
yes
Yes, but chances are the people on the C++ forum will be even more disgusted by the mere notion that you even thought about considering thinking about asking about using it.
...the people on the C++ forum will be even more disgusted by the mere notion that you even thought about considering thinking about asking about using it.
Oh I would just die if those popular kids on the C++ forums knew about my choice of programming language or the fact that it supports 'goto'. :D
C++ supports goto. ;)
In fact Stroustrup describes it as the "infamous" goto. :)
In fact Stroustrup describes it as the "infamous" goto. :)
Oh I would just die if those popular kids on the C++ forums knew about my choice of programming language or the fact that it supports 'goto'. :D
I got a place I would like them to 'goto'. =P
It's just another preference debate. Don't avoid it because people who don't prefer it call it stupid. Who cares.
Tachyon, you should just go with strict mode and use goto. Program the way you're most comfortable with.
Tachyon, you should just go with strict mode and use goto. Program the way you're most comfortable with.
Thanks for the advice. The fact is that my original post was simply saying that "goto" doesn't work as advertised...but I had already implemented a 'proper' solution before I even posted it.
For the record, I only use SuperStrict. I think the compiler should default to SuperStrict and require a command like "SuperLax" if you want to program lazily. ;)
For the record, I only use SuperStrict. I think the compiler should default to SuperStrict and require a command like "SuperLax" if you want to program lazily. ;)
Hehe, if only... (it would save us like 12 bytes of code!!)