[Coco] C VS Basic Coco

Rob Rosenbrock bester at adamswells.com
Thu Feb 15 08:31:37 EST 2018


> Date: Wed, 14 Feb 2018 17:06:38 +0000
> From: Bill Gunshannon <bill.gunshannon at hotmail.com>
>
> Ask Dykstra.  Or just look at the decades of research into why GOTOs are
> bad.
> In one of my last professional programming gigs I took more than a dozen
> programs heavily laced with GOTOs (true spaghetti code!!) and using proper
> structured programming removed all of them.  While I am not one who
> heavily
> favors standards bodies I think when they decided to come up with a BASIC
> standard it should have deprecated the GOTO entirely.
>
> bill
> ==============================================
> While I can understand that there is such a thing as to many GOTOs, it's
> very useful in some cases. You can misuse anything! A GOTO statement is
> the simplest way to call up a subroutine, such as in a program menu.
> Really simple code -- I haven't coded in so long I can't remember the real
> code for a keypress... but "IF X THEN GOTO 500" is pretty darned simple
> and handy for calling a subroutine from a menu. Hmm... would be a line for
> key polling, then a list of GOTO lines for the selections.... or a range
> in one line... I forget!!
>  Frank Swygert
>  Fix-It-Frank Handyman Service
>  803-604-6548

There wasn't much you could do to escape GOTO/GOSUB in the TRS-80
computers. Without a command like the CASE statement, you need to have
some other way of branching.

But for your example, didn't we have the option to use "ON X GOTO 500,
600, 700, 800..." instead of a list of GOTO lines?

For optimisation, though, you want to get rid of each that you can.
Whenever the interpreter sees GOTO/GOSUB, it searches through the code
from the first line until it finds the line number referenced. Ideally,
you'd place the most used subroutines at the beginning, and the
initialization code at the end.



More information about the Coco mailing list