Re: Stop Run vs GoBack



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.


.



Relevant Pages

  • Compiler positions available for week ending September 16
    ... advertise a position having something to do with compilers and must also ... Software Design Engineer ... The Visual C++ team is working hand in hand with the Windows division ... on enhancing the appeal of Vista and Windows 7 for ISV developers and ...
    (comp.compilers)
  • Re: Mechanical Aptitude Test
    ... Why is there junk code? ... Sometimes down to the indivudual transistors ... There are teams that suport the compilers, ... Computer simulation of the design was not a reality. ...
    (alt.machines.cnc)
  • Re: Stop Run vs GoBack
    ... 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 ... Exit Program ... If you really think that COPYed procedure code might be sensible then ...
    (comp.lang.cobol)
  • Re: free question
    ... > design, that's a bug aborted ... At least the standard is nothing more than a collection of practical ... behavior of compilers, unifying them. ... Rewiting things needed to be properiatry is hard enough, ...
    (comp.lang.c)
  • Re: What is Forth best at?
    ... Mark Bernstein is quoted as follow: ... in software design. ... Turbo Pascal defeated UCSD ... C had been around for a while, and the compilers always compiled to ...
    (comp.lang.forth)