Re: Bad habits of GOTO-using programmers



On Tue, 11 Nov 2008 20:42:57 -0800 (PST), Richard <riplin@xxxxxxxxxxxx> wrote:

On Nov 12, 4:49 pm, Robert <n...@xxxxxx> wrote:
On Tue, 11 Nov 2008 08:10:52 -0700, Howard Brazee <how...@xxxxxxxxxx> wrote:
On Mon, 10 Nov 2008 22:29:38 -0500, Robert <n...@xxxxxx> wrote:

No, but the -exit paragraph SIMPLIFIES exiting. In the case of ..

   PERFORM Para1

Para1.
   ....
   ....
Para2.

.. when the program reaches the end of Para1, it must decide whether to return or fall
into Para2. That decision consumes time and energy. Perhaps it's only one joule, but
during an energy crisis with high gas prices, every little bit helps. For reference, one
drop of beer, as from an eyedropper, contains 100 joules of energy. Could YOU make 100
correct decisions on one drop?

In the simplified case of ..

   PERFORM Para1 THRU Para1-exit

Para1.
   ....
   ....
Para1-exit.
   EXIT.

Para2.

.. the compiler can tell from the similarity of names that Para1-exit is the end of Para1.
The fact that it contains only the word EXIT confirms its function. There is no
possibility of falling off Para1-exit into Para2, so no decision is necessary. Knowing the
return is unconditional, the compiler can omit the decision making code.

The word EXIT may confirm intent, but can be in any otherwise empty
paragraph.

One can still drop through a performed paragraph, so the compiler
needs to have code to account for that possibility.  

What happens when two performs have a common exit? Consider:

 main.
    perform section-a

 section-a section.
 a.
   ....
   perform a-x
   ...
 a-x.
     continue.
D   display 'exiting'.

 section-b section.
D    display 'Please help me, I'm falling'.

One would expect this to be covered by the Standard, but it's not. What happens depends on
the compiler.

You are talking nonsense again, Robert.

The standard certainly does cover overlapping performs and has done so
since at least as far back as '74, probably '68 or even earlier.

(14.5.9, Overlapping operands)
37) PERFORM statement. The results of the execution of overlapping PERFORM statements are
undefined.

(14.8.27, PERFORM statement, general rule 11)
11) The results of executing the following sequence of PERFORM statements are undefined
and no exception
condition is set to exist when the sequence is executed:
a) a PERFORM statement is executed and has not yet terminated, then
b) within the range of that PERFORM statement another PERFORM statement is executed, then
c) the execution of the second PERFORM statement passes through the exit of the first
PERFORM statement.
NOTE Because this is undefined, the user should avoid such an execution sequence. On some
implementations
it causes stack overflows, on some it causes returns to unlikely places, and on others
other actions can occur.
Therefore, the results are unpredictable and are unlikely to be portable.

The Micro Focus Way
    The exit to main is destroyed by the second perform of a-x. The section does not exit,
execution falls into section-b. But wait, it gets better. If a-x were changed to an empty
paragraph, by turning off debug, the optimizer would have discarded perform a-x, which
would make it return as expected.

You are talking nonsense again, Robert, and spreading more Wagnerist
mis-information.

Microfocus implements the standard and even has extensions to remove
some of the limitations of the standard. See PERFORM-TYPE directive.

PERFORM-TYPE

MF Only the exit point of the innermost PERFORM currently being executed is recognized
and its return jump taken.

OSVS The exit point of any PERFORM statement currently being executed is recognized if
reached; the return jump taken is the first reached. PERFORM statements with the same exit
point can be nested to a depth of two (one inner and one outer). If they are nested
deeper, they do not return correctly. The end of a section is regarded as the same point
as the end of its last paragraph.

PERFORM-TYPE"OSVS" provides compatibility with the mainframe behavior of OS/VS COBOL,
DOS/VS COBOL, VS COBOL II and COBOL/370.

RM The exit point of any PERFORM statement currently being executed is recognized if
reached; the return jump taken is the first reached. PERFORM statements with the same exit
point cannot be nested; if they are they do not return correctly. The end of a section is
regarded as a separate point from the end of its last paragraph.


Microfocus copes fine with your code and does the performs correctly
without dropping out as you claim.

Do you _ever_ test anything ?


The Ryan-McFarland Way
    Almost the same except section exits are distinct from paragraph exits. In this case,
it works as expected. If main had said perform a thru a-x, the second trip through a-x
would have fallen into section-b.

The Realia Way
    Works as expected. Returns are pushed on the stack.

The Mainframe Way
    Works as expected, HOWEVER exits can only be nested TWO DEEP.  A third perform of a-x
would have destroyed the return to main. Try to figure that one out at 2am.


.



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: 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: Bad habits of GOTO-using programmers
    ... That decision consumes time and energy. ... The fact that it contains only the word EXIT confirms its function. ...     perform section-a ...     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: EXEC and Windows XP
    ...   I'd say I'm pretty much a "noob" with tcl, but in reality, I'm very ... noob, ... to indicate routine execution). ...
    (comp.lang.tcl)