Gotos and Gosubs

BlitzPlus Forums/BlitzPlus Programming/Gotos and Gosubs

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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...