I don't believe the use of GOTO is bad practice in terms of the efficiency and 
performance of the program, but its convenience often leads to lazy "spaghetti" 
code design which, in turn, usually leads to bugs.


The use of RETURN is a much tidier way of breaking out of a SUB or FUNCTION, 
which has the effect of "GOTO END OF SUB/FUNCTION". It will then take you to 
the next line in the SUB/FUNCTION which made the call.


It is always possible to write and position IF, SWITCH statements or loops in a 
way to avoid the need for a GOTO statement. The code following the 
corresponding label could, for example, be contained in a separate SUB or 
FUNCTION, which makes the code tidier and makes it easily reusable within the 
program.


I certainly would not say that programmer who uses lots of GOTO statements is a 
bad programmer (as long as the program works correctly and efficiently) but I 
believe that few developers would choose to maintain code written by somebody 
else containing lots of GOTO statements.


It's important to stress that this principle is not unique to Gambas. Nearly 
all programming languages support the concept of the "GOTO" (even C), and VB 
actively encourages it in its error handling, which is why Gambas is so 
superior.


Nige
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to