[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Computing Editorial (please read)
Marsha (menacechgo@aol.com) writes:
> [posted and mailed]
>
> "Dave Althoff, Jr." <dalloff@gcfn.org> wrote in
> news:b0g1ie$gvd$1@ronco.freenet.columbus.oh.us:
>
>> And I wish the computer science snobs would not be so rough on the poor
>> GOTO.
>
> Same here...
> A nice old fashioned GOTO to a line number is easier to track than a
> subroutine/function call which you then need to track down somewhere in the
> listings.
> Not to mention that even in assembly, unless the program is run once all
> linear, it'll be full of JMPs,JSRs and RTSs, the equivalant of BASIC GOTOs,
> GOSUBs.
>
> Marsha (Computer science major {non-snob} )
>
>
But what do you do at the other end of the GOTO? Either it's the end
of the program, or you'll have to put another GOTO at the end, to send
you somewhere else. I don't think the taboo against GOTOs concerns
itself so much with the initial jump, but that spaghetti at the
end to bring you back. And probably too the weaving that some might
do for no particular reason other than that you can do it, or
because they can't properly visualize the layers of the program.
Subroutines make for much cleaner code. I don't believe I was
reading about the evil GOTO when I started programming, but I learned
pretty early the usefulness of subroutines. Map out the main loop,
and start with dummy subroutines. Then work on the subroutines. Or,
work on the subroutines first, figuring out little bits of code
by themselves, and then fitting them together with some other code
later. I found it all worked out quite nicely, the experience pointed
to the usefulness.
Since the 6502 didn't have conditional jump to subroutines, I even
figured out myself that it made sense to jsr to the condition testing
when then branched to the subroutines. An rts at the end of the subroutine
then brought you back up to where you'd originally jumped from, rather
than having to put code in the conditional testing.
Michael