08-10-2024, 04:55 AM
Some folks are vehemently against GOTO statements. I tend to find them to be the most elegant, and simple solution in many cases.
Are you nestled 12 loops deep, within countless IF and SELECT and other branching statements, and then suddenly you find yourself done with everything that single branch of conditions can do?
GOTO Finished_Processing
Wooooo.... Now, WTF is any simpler than that to understand? It leaps you out of all those conditions/loops/branches and ... by golly, it takes you... to the beginning of processing! Actually, I would think that anyone who speaks the language could tell you exactly where that GOTO is going to take you -- to the end of the Processing code segment!
GOTO Start <-- Gee willikers, this one is hard to understand
GOTO RedoInput <--- Gosh, I'd never know where this is going to send me, or what its purpose is
GOTO PrintResults <--- Umm... I'm guessing this is where we ask for a lot of user input. Right??
The most important thing with GOTOs is that the LABEL they link to has to be descriptive, and that they don't immediately branch off some friggin place else, like some of the older BAS programs used to. NOBODY can puzzle out that spaghetti crap!
10 GOTO 20
20 GOTO 40
30 GOT0 50
40 GOTO 30
50 GOTO 60
60 ON x GOTO 10, 20, 30, 40, 50
70 GOTO 0
WTF????
Numeric labels are a FAIL with GOTO. A GOTO needs a very descriptive and unique label to help understand and state its purpose.
A GOTO should never directly lead into another GOTO. That's the stupidest thing in the world. Just have the first GOTO go directly where it needs to be, without leaping through a dozen hoops with middle men!
Gotos really aren't bad in use when coding. They're there for a simple, and powerful purpose.
They just really, REALLY, REALLY-REALLY suck bad when they're misused!
Are you nestled 12 loops deep, within countless IF and SELECT and other branching statements, and then suddenly you find yourself done with everything that single branch of conditions can do?
GOTO Finished_Processing
Wooooo.... Now, WTF is any simpler than that to understand? It leaps you out of all those conditions/loops/branches and ... by golly, it takes you... to the beginning of processing! Actually, I would think that anyone who speaks the language could tell you exactly where that GOTO is going to take you -- to the end of the Processing code segment!
GOTO Start <-- Gee willikers, this one is hard to understand
GOTO RedoInput <--- Gosh, I'd never know where this is going to send me, or what its purpose is
GOTO PrintResults <--- Umm... I'm guessing this is where we ask for a lot of user input. Right??
The most important thing with GOTOs is that the LABEL they link to has to be descriptive, and that they don't immediately branch off some friggin place else, like some of the older BAS programs used to. NOBODY can puzzle out that spaghetti crap!
10 GOTO 20
20 GOTO 40
30 GOT0 50
40 GOTO 30
50 GOTO 60
60 ON x GOTO 10, 20, 30, 40, 50
70 GOTO 0
WTF????
Numeric labels are a FAIL with GOTO. A GOTO needs a very descriptive and unique label to help understand and state its purpose.
A GOTO should never directly lead into another GOTO. That's the stupidest thing in the world. Just have the first GOTO go directly where it needs to be, without leaping through a dozen hoops with middle men!
Gotos really aren't bad in use when coding. They're there for a simple, and powerful purpose.
They just really, REALLY, REALLY-REALLY suck bad when they're misused!