Re: Stop Run vs GoBack
- From: Richard <riplin@xxxxxxxxxxxx>
- Date: Sun, 24 Jun 2007 22:57:25 -0700
On Jun 25, 3:15 pm, "William M. Klein" <wmkl...@xxxxxxxxxxxxxxxxx>
wrote:
Well, NO - you wouldn't have to test it if you design (from scratch) a program
to be usable as BOTH a main and SUB program. This can be done on an IBM
platform (or with any of the MULTI-IBM compatible compilers such as Fujitsu,
Micro Focus, RM - and any '02 conforming compiler) by using GOBACK.
While one can design a program to be both a MAIN or a SUB it is
usually not useful outside a mainframe environment. I understand that
a MAIN can have a LINKAGE SECTION filled by command line parameters
(or similar) on mainframes but this is not usually the case on, say,
PCs or Unix.
This means that if the LINKAGE SECTION exists for the purpose of being
called then using this as a MAIN will fail if any reference is
actioned to a L-S item. Because of this it is not a good idea to
"design (from scratch) a program .." if this is not only for use on
IBM. A sensible design can be made on either by creating a called
program and a simple MAIN program that creates data areas and calls
the subroutine. ie there is no actual point for a design that can be
MAIN or SUB, except possibly on IBM mainframe.
In any case Fujitsu on Unix or PC _requires_ that a program be
nominated at compile time as MAIN or called so one executable cannot
be both.
For compilers allowing an extension to the '85 Standard which allows EXIT
PROGRAM to be followed (immediately) by STOP RUN, then code:
Exit Program
Stop Run
It is not an extension that one be followed by the other in execution
sequence, only that the full stop be omitted and this is regardless of
whether both occur in the execution sequence.
ie:
EXIT PROGRAM
.
STOP RUN
.
does not require any extension. Each statement must be the last in the
sentence it is in.
GOBACK, however, is always an extension prior to '02 standard.
of course, unlike GOBACK this may not work within a Method or user-defined
function. Therefore, as I said before, use GOBACK unless you REALLY think your
code will ever be compiled on a system without support for it.
IBMers tend to be completely anal about GOBACK because, it seems, they
were taught it in 1902 and never bothered to learn real COBOL (ie EXIT
PROGRAM).
I have no idea whether any particular implementation would handle EXIT
METHOD correctly with a GOBACK but why bother to find out when a
perfectly good verb has been designed to do this correctly without
having to check.
P.S. GoBack within a METHOD or FUNCTION avoids needing to know which type of
"procedural" (i.e Procedure Division) your code is in.
How would one _not_ know.
This allows for "common
code" to be brought in via a COPY statement (without REPLACING).
'COPYed' procedure code is very poor design. If you want to have
'common code' then write a method or function with the code and call
it. In any case, even with COPYed procedure code, it is unlikely to
be useful to have the EXIT ~ within it, this can follow the COPY
statement giving better reuse - or just have it fall off the end of
the code.
I would always advise against having code that is positionally
dependent. Any EXIT ~, GOBACK, or GO within a block of code makes it
less reusable. It would make a difference if it was 'dropped through'
or performed, or perormed in-line and thus is likely to cause bugs.
If you really think that COPYed procedure code might be sensible then
you should ensure that it is 'pure' code and thus GOBACK would be
bannished from it. This leaves your argument moot.
.
- Follow-Ups:
- Re: Stop Run vs GoBack
- From: Howard Brazee
- Re: Stop Run vs GoBack
- From: Howard Brazee
- Re: Stop Run vs GoBack
- From: Pete Dashwood
- Re: Stop Run vs GoBack
- References:
- Stop Run vs GoBack
- From: William M. Klein
- Re: Stop Run vs GoBack
- From: Pete Dashwood
- Re: Stop Run vs GoBack
- From: William M. Klein
- Stop Run vs GoBack
- Prev by Date: Re: COMP-1 and COMP-2 resolution on unix (using microfocus)
- Next by Date: Re: COMP-1 and COMP-2 resolution on unix (using microfocus)
- Previous by thread: Re: Stop Run vs GoBack
- Next by thread: Re: Stop Run vs GoBack
- Index(es):
Relevant Pages
|