Quote:
Originally posted by The Lucas
Could someone please explain the purpose of gosub? It is just a goto with a return statement, totally worthless.
|
GoSub is an important feature from the basic lineage. Remember, pBasic is used for much more than just our robots.In the BASICs, a sub-routene is like a void function in C/C++/Java. An important aspect of a subroutene is that it will always go back to where it was called from. This is especialy important in code recycling. Imagine if you had to keep track of every place that a function is called from! It also helps with organization; every section can have it own subroutene that each subsystem can work on independently of the rest of the program.