On Friday, 15 July 2016 23:34:20 UTC+2, Edward Gould  wrote:
> Not to get into structured programming issue at all (I think it has its good 
> as well as bad points). But the idea (I thought) of readable programs, alter 
> goto’s (in my mind) destroy simple readability as what you read does not 
> represent a necessary reality.
> 
> Ed

TOP-OF-LOOP.

    [some stuff doing the read and dealing with EOF]

JUMP-OVER-HEADER.
    GO TO.

PROCESS-HEADER.

    IF RECORD-TYPE EQUAL TO "00"
        [do some stuff].

    ALTER JUMP-OVER-HEADER TO PROCEED TO PROCESS-REST-OF-FILE.

PROCESS-REST-OF-FILE.

    [process the rest of the records].

    GO TO TOP-OF-LOOP.


Why do that? It was faster. When would you do that? In the days when saving an 
IF vs doing a branch counted.

Another unproblematic use was "doing a fast 'perform'". The documentation would 
warn against using PERFORM for performance reasons. However, with simple use of 
ALTER, you can "GO TO" a block of code and "GO TO" back to a label after your 
original GO TO (I admit to doing this in SCRIPT/VS to produce system design 
documents).

The problem becomes when ALTER is used to instead implement business logic. In 
a program (a deck of cards) which is already potential-spaghetti with plain GO 
TOs as well. Was that the right thing to do at the time? I don't know, I wasn't 
there. If programmers had stuck to simple, advised even, use of ALTER, would it 
have its bad rep? I don't know.

The point is (or was intended to be) that ALTER allows certain things. With a 
"best practice" use of ALTER, what complaint is there? With EXIT PARAGRAPH and 
"best practice" there is one thing, but are people going to stick to "best 
practice"?

GO TO in modern COBOL programming is a "simplify the code" panacea. Or 
"simplify the code that I'm writing at the time, not necessarily keeping the 
program simple" anyway. If EXIT PARAGRAPH is used as a "structured" replacement 
for the use of GO TO then bad things are going to happen when a label is added 
(for a GO TO, or to allow another particular EXIT PARAGRAPH to do what is 
"wanted").

How is that *not* going to happen? "I don't use GO TO, I use 'structured' 
constructs". Which are disguised, no-label, GO TOs....

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to