Re: TIB: Old topic-Goto/Lbl statements


[Prev][Next][Index][Thread]

Re: TIB: Old topic-Goto/Lbl statements




Code which utilizes GOTO is referred to as spaghetti code.  It is bad
only if it ever has to be modified, then it becomes almost impossible
for a coder to decode someone's spaghetti code, because they have to try
and follow each goto around the program, instead of simply viewing the
code from top to bottom.

Instead of jumping all over the program with GOTOs, one should use
while/for loops, and if then else endif constructs.

All of the looping and test constructs generally take less cpu time than
a goto.

In theory it is possible to make any program without a single goto.  In
practice it is not always the most efficient way, but it rarely happens
that a goto is *needed*.

Subroutines are very important as well, but are not supported as such on
the TI.  It's best to make often used parts of the program available in
a seperate program.

Using GOTOs is frowned on, as you will find out in "structered
programming" books and courses.  As always, assembly is completely
different, and different 'rules' apply there.

Give me a simple program that uses goto, and I can show you how it would
appear were it programmed without gotos.

-Adam


Grant Winney wrote:
> 
> >Or do as I do and don't use either the Goto or Lbl statements at all!
> >I guess I was just lucky enough to have a teacher that taught me how >to
> >make programs without crappy Lbl/Goto coding. =)
> >
> >-Miles Raymond      EML: m_rayman@bigfoot.com
> >ICQ: 13217756       IRC: Killer2        AIM: KilIer2 (kilier2)
> >http://www.bigfoot.com/~m_rayman/
> 
> I'm curious, Miles, how do you write a program without_any_Goto or Lbl
> statements?  I admit I'm no expert at Basic programming, and I don't really
> know what I'm expecting here, but could you maybe write back (or e-mail me)
> with a few examples of instances when most people would use Goto/Lbl
> statements, but you could use something better instead?  (Wow, really long
> sentence! :)
> 
> This would probably just be a pain in the butt, but it could be helpful to
> more programmers than just myself.
> 
> Thanks in advance,
> -Grant Winney
> <cosmo70@hotmail.com>
> 
> _______________________________________________________________
> Get Free Email and Do More On The Web. Visit http://www.msn.com


References: