Post Reply 
TI Conditionals & Spaghetti Code
05-18-2024, 11:46 PM
Post: #2
RE: TI Conditionals & Spaghetti Code
(05-18-2024 10:25 PM)Matt Agajanian Wrote:  Hi all.

Yes, the TI library of Solid State Modules, Magnetic Cards, hundreds of Users Groups have contributed massive amounts of programs built around the SR-52, SR-56, and the 58/59 using conditionals with the automatic Go To for line numbers and labels.

But, wouldn’t the automatic transfer of a Go To instruction result in a scramble of program locations and execution flow instead of a well organized code?

I thought using Go To would just create a confusing path of programming and execution.

Don't believe everything Dijkstra says. Virtually every CPU eventually translates comparison instructions and loops into jumps. GOTO, like any programming instruction, can be misused but it can also be used to make the logic of a program clearer. Keep your code organized into one way in, one way out and GOTO doesn't get in the way at all.

Structured method:
Code:
DO
    <some code>
    x=x+1
LOOP UNTIL x>10

Using GOTO:
Code:
LBL A
    <some code>
    x=x+1
if x<=10 GOTO A

Sure, these are trivial examples but they illustrate they GOTO doesn't need to create spaghetti code. The meaning of both segments is pretty clear.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: TI Conditionals & Spaghetti Code - toml_12953 - 05-18-2024 11:46 PM



User(s) browsing this thread: 5 Guest(s)