Logo
Also from from Blinky
The Worldwide Squirrel Shooters Association (Photography, that is.)
The Usenet Improvement Project
NEW at Blinkynet
My Old Girlfriend

GOTO - A Virtual Lifesaver

Norman L. DeForest


A few years ago I read about how a FORTRAN programmer used lots of GOTOs to solve a problem he had.

Background

  1. The version of FORTRAN he was using allowed multiple statements on a line using '$' as a statement separator.
  2. Many of his programs had tens of thousands of statements.
  3. The system used punch cards.
  4. He couldn't take the cards to the machine himself. The protocol at his place of work required that all jobs had to be submitted to a central office and, from there, the card decks would be taken by secretary to the computer and loaded by them.
  5. The secretaries had a bad habit of dropping card decks and getting them mixed up.
  6. Punching sequence numbers on the cards allowed them to be resorted but that had to be submitted as a new job -- with no guarantee that the cards wouldn't be dropped again after sorting and before being re-submitted for compiling.

His Solution

  1. He numbered every statement.
  2. Each card that had a GOTO was left alone since it jumped to another statement. (For conditional branches, that version of FORTRAN used arithmetic GOTOs where IF branched to one of three specified statements depending on whether the expression in the IF was negative, ro, or positive.)
  3. Each card that didn't have a GOTO had one added, going to the next card:
    ...
    ...
    12347 ...
    12348 SALARY = RATE * HOURS            $ GOTO 12349
    12349 OVERTIME = RATE * 1.5 * OVRHOURS $ GOTO 12350
    12350 ...
    ...
    ...
  4. He used colour-coded cards for the JCL[1], the first statement in the program, and the last statement in the program.

If the card deck was dropped and mixed up, he only had to find the colour-coded cards and put them in the right place. Regardless of the spaghetti-code nature of the rest of his program, it would compile and run correctly no matter what order the rest of the cards were in.

No amount of "structured programming" could have solved that problem. :)

[1] JCL: Job Control Language.


Original posted to alt.www.webmaster; Message-ID <Pine.GSO.3.95.iB1.0.1050905063156.22981A-100000@halifax.chebucto.ns.ca>


<-  Back to Computing/Other


Get Firefox No Google Groupers