Gotos and Gosubs

BlitzPlus Forums/BlitzPlus Programming/Gotos and Gosubs

Joerg B.(Posted 2004) [#1]
Hi!
Does somebody know, if Gotos and Gosubs are supported in future versions of BlitzPlus? (Still it can be useful - I like to use it just once or twice in a program) I heard, that the new BlitzMax doesn't support Gosubs anymore...
Thank you!!!


Perturbatio(Posted 2004) [#2]
As far as I know Mark will not be removing commands from B+, if any modification is to be made to the commandset, it is likely to be an addition.


Russell(Posted 2004) [#3]
There are certainly at least a few situations where goto and gosub could be useful, but I've yet to find a situation where it couldn't be done some other way.

On the other hand, goto is just 'slightly' faster than calling a function, etc, so if you're looking to squeeze evry last drop of performance out of your program, then they can still be of use.

I say keep them, but encourage people to use more 'modern' and 'friendly' methods to jump around your program.

Russell


Seldon(Posted 2004) [#4]
It would not be a nice idea to remove them, even C supports GOTO! Besides GOSUBs and (especially) GOTOs can be useful to add anti-debugger tricks to your code. Also in current Blitz version, it's better to use GOSUBs (instead of functions) when you don't need to pass any parameters as it's rather faster.


MSW(Posted 2004) [#5]
a GOTO is basicly a jump

A Gosub is basicly the same, except a memory adress is PUSHed onto the stack...then a jump to the subroutine...then the memory address is POPed back off at the Return call where a second jump is performed.

A Function is basicly the same as a Gosub, but with additional variable values being PUSHed onto the stack...jump to the function code...the variable values are then POPed off the stack...the function exectues...then at the return call the memory adress is poped off...a return value is PUSHed onto the stack...the return jump is made where the return value is POPed off.

If speed is an issue...especialy concerning nested loops... you are best avoiding jumps all together and just inlineing your code...