Re: Infinite Loops and Explicit Exits

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


Date: Tue, 16 Nov 2004 06:05:39 GMT

On 15 Nov 2004 11:15:08 -0800, riplin@Azonic.co.nz (Richard) wrote:

>Robert Wagner <spamblocker-robert@wagner.net> wrote
>
>> The only hardware change was the addition of stack(s). Early
>> compilers, not having hardware stacks, created them by chain-linking
>> register save areas (for CALL) or putting return addresses into an
>> array (for PERFORM). The mechanics have changed but the principle
>> hasn't -- programs store a return address SOMEwhere.
>
>Yes, they do. And in machines of my experience that was in the EXIT
>statement placeholder at the end of the PERFORM range. Actually the
>particular compilers did not require an EXIT as it would always add
>nulops at the end of each paragraph and section. A PERFORM would be
>done by 1) setting return address at end of scope, 2) jumping to the
>start of scope, 3) clearing the return back to nulops.
>
>> Cobol was advertised to be machine-independent. It sounds odd to now
>> hear 'The hardware made us do it.'
>
>Cobol was/is 'machine independent', but to be that the language had to
>cater for how implementations would be done on different types of
>hardware. The EXIT in its own paragraph was part of the language
>_because_ that is where the PERFORM return was stored on some
>machines.

No. There has always been a need to cater to single-paragraph
PERFORMs. Poorly optimized early compilers generated conditional exit
code at the end of EVERY paragraph. Thus, PERFORM A THRU A-EXIT ran
slower than PERFORM A because of extra code at the end of A.

>In fact, even on stack based machines, code at the end of each
>paragraph need to check somehow whether it is the end of a perform
>scope or is to drop through. It can't just 'return to last item on
>stack' because this is where _some_ PERFORM might be done.

At least one compiler provided an option to do exactly that. By
selecting the option, you promised the compiler there were no
fall-thru paragraphs, such as the one before A-EXIT. I always used
that option on Realia.



Relevant Pages

  • Re: Is it possible to use the value of the PROGRAM ID within the source code?
    ... The EXIT statement was there to cater for the very early compiler code ... While not all compilers required this, it certainly was the case with ... some compilers that I worked with that pre-dated the '68 standard, ... paragraph without a statement until the '74 standard. ...
    (comp.lang.cobol)
  • Re: Para1 THRU Para2
    ... HB>>> The best way to exit a paragraph this way is with an EXIT ... r> putting everything in one sentence makes the nesting too deep. ... One has to look at this logically, and create a transformation ...
    (comp.lang.cobol)
  • Re: COBOL aint quite dead - yet !
    ... sometimes I will replace the EXIT. ... the exactly the same label made into a comment. ... Putting in a paragraph label is a lightweight ... possibility of errors such as goto the wrong one, ...
    (comp.lang.cobol)
  • Re: COBOL aint quite dead - yet !
    ... sometimes I will replace the EXIT. ... was via the last paragraph. ... In Cobol a label may be the target of a goto, a perform, a drop ...
    (comp.lang.cobol)
  • Re: Infinite Loops and Explicit Exits
    ... Massive changes qualify as a 'redesign'. ... A perform of a section or a perform of a paragraph is no matter as both ... Afterwards they would reset the exit point back to what it ... > was a NULop. ...
    (comp.lang.cobol)