Re: Infinite Loops and Explicit Exits

From: Robert Wagner (spamblocker-robert_at_wagner.net)
Date: 11/02/04


Date: Mon, 01 Nov 2004 23:04:29 GMT

On Mon, 1 Nov 2004 09:33:28 -0800, "Chuck Stevens"
<charles.stevens@unisys.com> wrote:

>What cannot be determined in all cases at compile time is whether a
>statement appears within the scope of an *out-of-line* PERFORM range, which
>is now defined basically as all those statements executed starting with the
>first statement at the beginning of the PERFORM range and ending when
>control is passed back to the PERFORM.
>
>That's one reason why I suggest that both EXIT PERFORM and EXIT PERFORM
>CYCLE be treated as CONTINUE at execution time if they are executed outside
>of an execution-time PERFORM range.

No, no. The programmer explicitly said to exit the current block of
code. If not under control of a PERFORM, EXIT PERFORM should be
treated as EXIT PARAGRAPH.

EXIT PROGRAM has the same flaw -- it becomes CONTINUE if the program
has not been called. GOBACK takes the more reasonable action of STOP
RUN.

Consider this example:

 COPY-RECORD.
     READ input-file
     IF STATUS-CODE-1 NOT EQUAL TO ZERO
         EXIT PERFORM
     END-IF
     MOVE input-record TO output-record
     WRITE OUTPUT-RECORD.

Running this under the debugger rather than under a PERFORM will write
garbage to the output file.

>Raising some sort of exception, instead of simply ignoring the EXIT PERFORM,
>would certainly be another reasonable approach when the statement was
>executed outside of a PERFORM range (just as is the case for RETURN/RELEASE
>outside of SORT/MERGE input/output procedures) -- EC-FLOW-EXIT-PERFORM,
>perhaps? I'd argue against it being fatal, though ...

I'd welcome that. Also, an exception for any paragraph fallen into
when an option (STRUCTURED?) is set.



Relevant Pages

  • Re: Bad habits of GOTO-using programmers
    ... The fact that it contains only the word EXIT confirms its function. ...     perform section-a ... The results of the execution of overlapping PERFORM statements are ...     The exit to main is destroyed by the second perform of a-x. ...
    (comp.lang.cobol)
  • Re: CRC reverse engineering
    ... exit. ... She'd rather allege still than name with Mike's continued ... execution. ... When doesn't Allahdad need at least? ...
    (sci.crypt)
  • Re: Bad habits of GOTO-using programmers
    ... The fact that it contains only the word EXIT confirms its function. ...     perform section-a ... The results of the execution of overlapping PERFORM statements are ...     The exit to main is destroyed by the second perform of a-x. ...
    (comp.lang.cobol)
  • Re: Most dependable way to run system commands
    ... Eventually I'd like to bring the execution of a few system commands ... specific execution issue (it dealt more with executing Perl code)). ... Unix and many similar systems, the exit status is an integer, with 0 ... variable after running a command via system or backticks. ...
    (perl.beginners)
  • Re: Bad habits of GOTO-using programmers
    ... The fact that it contains only the word EXIT confirms its function. ...     perform section-a ... The results of the execution of overlapping PERFORM statements are ...     The exit to main is destroyed by the second perform of a-x. ...
    (comp.lang.cobol)