From: lasner@watsun.cc.columbia.edu (Charles Lasner)
Newsgroups: alt.folklore.computers
Subject: Re: Branching in HLL vs. Assembler (was Re: The need for an assembler)
Date: 3 Sep 92 04:36:32 GMT
Reply-To: lasner@watsun.cc.columbia.edu (Charles Lasner)
Organization: Columbia University

In article <1992Sep1.083701.2898@pollux.lu.se> magnus@thep.lu.se (Magnus Olsson) writes:
>In article <1992Aug31.160756.23324@news.columbia.edu> lasner@watsun.cc.columbia.edu (Charles Lasner) writes:
>>In article <1992Aug28.221421.18061@ttinews.tti.com> hollombe@polymath.tti.com (The Polymath) writes:
>>>
>>>The problem isn't so much with the GOTO as with the lack of a COMEFROM.
>>>
>>>Suppose you're neck deep in the bowels of a multi-megabyte system and you
>>>come across a label in the source code.  There could be any number of
>>>GOTOs in the code that branch to that label.  Even if the original
>>>programmer was kind enough to provide a comment listing them all (I've
>>>only seen that once and I wrote it), figuring out which particular one
>>>you're concerned about can be a nightmare. (In a language like BASIC the
>>>problem is even worse since _every line_ can be the target of an arbitrary
>>>number of GOTOs).
>>
>>a)	That's ludicrous since no code does a GOTO the middle of a module
>>therefore the largest thing to worry about is the size of the module you
>>are working on where the label exists.
>
>With all respect for your great experience, have you ever programmed
>in BASIC? In BASIC (I'm talking about real, honest-to-God, macho
>interpreted BASIC, with one-character identifiers, and not one of
>those wimpy, effeminate pseudo-Pascals marketed today), your whole
>program is one big module, and you can jump literally *anywhere*. Of
>course, you probably wouldn't be able to use those BASICs to write
>multi-megabyte modules, but even a 64 K module can be pretty ard to
>debug... 

Yes, spaghetti code can happen in any language, probably even PASCAL if you
work at it :-).

BTW, I have 15,000 line assembler "modules" as well; they ain't spaghetti code.

>
>For example, it was common practice among certain programmers to write
>"clever" code like this (and this is just a simplified example, actual
>code would probably look much worse):
>
>1000 FOR I=1 TO 1000 
>1010 REM do something here
>1500 M=K
>1510 NEXT
>1600 RETURN
>...
>
>2000 GOSUB 9876
>
>...
>
>9876 IF J=K THEN 9900
>9880 FOR M=1 TO 100
>9890 GOTO 1500
>9900 RETURN
>
>
>Now, to quote one of the sacred annals of hackerdom (*), "put *that*
>in Pascal's pipe and smoke it!"
>
>(Note especially that the NEXT statement in line 1510 refers to
>different control variables depending on from where the loop was
>entered). 
>
>(*): I'm of course referring to "Real Programmers don't Write Pascal".

Cute, but that's "playing" with a language instead of using it.  Couldn't
you use statements like NEXT I to enforce some structure?  (No, I don't
mean what PASCAL smokers mean by that :-).)

Years ago, people wrote Fortran code that stored into FORMAT statements,
so what? :-)

>
>
>Speaking of spaghetti code, one common reason for writing spaghetti
>code was (is?) the lack of a line-renumbering utility in primitive
>BASICs: suppose you had written something like
>
>100 A=B
>102 X=Y
>
>and then realized you needed to fit another ten line of code between
>lines 100 and 102? Well, of course you wrote something like
>
>100 A=B
>101 GOTO 1000
>102 X=Y
>
>
>1000 REM put extra code here
>...
>1100 GOTO 102
>
>
>Horrible? Yes, of course, but the alternative (manually renumbering
>maybe hundreds of lines) would be even worse.

Yes, a BASIC analogy to my tale of the punched card people.

However, even 4K PDP-8 POLY BASIC can renumber its statements, and that goes
back to 1969, so this must be some really crummy BASIC.  (Anything to do
with Microsoft? :-))

cjl
Newsgroups: alt.folklore.computers,comp.unix.misc