I generally get by with control structures like case (select/when), 
if/elsif/when, iterate and leave, but I unashamedly use GOTO, when it is the 
cleanest way to do something; I refuse to avoid a useful construct just because 
it is not politically correct. In the case of COBOL, I consider the out of line 
PERFORM to be far more dangerous. I have a similar issue with REXX; it does not 
have lexical scope, and you can fall into a procedure.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Discussion List [IBM-MAIN@LISTSERV.UA.EDU] on behalf of 
Bernd Oppolzer [bernd.oppol...@t-online.de]
Sent: Sunday, June 7, 2020 6:17 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Goto Statements (was: COBOL Question)

Thank you very much for the link to that article; I did not know that
before.

When I started to work on the Stanford Pascal compiler in 2011, it had
about 20 to 30 labels and Gotos
(6000 lines of source code).

http://secure-web.cisco.com/1pX2kW19qrUp9yyoP4cfhRRs2ehNXyOiR8ZzrLZPfjVUIuBM5B0cu5ExeRn-gVhTqtsFmQqRCeX1kWt8GVLJyqBetd-We06QY6gkbVWv3QC1o-NEVdaqRH6t2DH39gZvw0-3Jihs-F5wMJmmJUpgr5TRe-YayUTWUwX8Ei1zyTXm3YUVjbqPmkwLafqSKfBfd7dffvaXZkRLue6QQlmtfeaQ2d1GitnaBXNkNX9uaLzv2H5RvX0D-L61XkawFX-Eek9LsXAx0ycMXFpGNImgy5z9eMSon1P95x3V9wTqj1Pw6li8X2jwgFaZf1K_OkHNP4J_e51OIlCSPmnr61YIXw_-N0KKbOmQDuxiLobG46E7__kPTDeUP6oVHTPSdfvi8bQ6hhgm0MAe1y0jWiSnvezjXncFaNcNhThLUdm5bv1vkXAAvMM89ntcCkUAiNb44/http%3A%2F%2Fbernd-oppolzer.de%2Fjob9.htm

In the meantime, I omitted most of them, but this was only possible,
after I added
CONTINUE and BREAK (for all three types of loops) and RETURN (to do
early returns from procedures),
which are not present in Standard Pascal.

http://secure-web.cisco.com/1Km_bU1ZhlXrKXvTgabvFbHyaYXnzrcmk29Sl8AEjRAtYm4DFVcOJwHT6UIto3Tv4KffE0e3UQGWhHuGzdbAd-m2WCw4XJOZavBvuPWSV9525c1v_HDcAvHJIHIA6np8gqeDNP9bJFESQpyaSyQivd7HdNVnZTzfPKzWC2Bcv82b4oS_eTA6_H7fYXeBcHDP76oBOMOyB-kYDewa6mzanpF2bWJDRsXBYrQsW5qSE7Fk3sggZqGbEAYcJlLHNrF8IZSg3UmLFP_nCC5K9ftu_qXhfj-mM8dDUC52sS0YD1lON2dpIK7GgMzQ9WudkLKf-Z43IOBnRltKuxHzXUiTetyx7siAqIytTDFJ5C-29z1pojvBmeRIHtb0-K74gMS83Q9i2y7Sj7nPydr_ou22wlo62sHVFJ4yS9RU4NANqxMEEbsrJuWL_ZM1qQjZPEuRa/http%3A%2F%2Fbernd-oppolzer.de%2Fjob9i004.htm

The compiler now has 22000 lines of code (much more function than the
2011 version), but much less gotos.

Back to Cobol:

IMO, many of the observations of the 1960s are still valid for today's
modern COBOL:
if you use (for example) inline PERFORM and all the possibilities to do
structured programming
in COBOL and try to reduce the use of Gotos to an absolute minimum (for
example: leave the
program in case of catastrophic errors), then your programs will be
easier to read and maintain;
at least that's what I am experiencing.

BTW: I added so much function to the New Stanford Pascal compiler in the
years since 2011 (and I ported
it to Windows and Linux etc.), that I recently was able to use it to
write a COBOL source code formatter
using this compiler, which is very helpful when doing maintenance work
on (large old) COBOL programs.
I am thinking about enhancing this source code formatter (which does
COBOL parsing to some degree)
to get meta information out of the COBOL source code, for example file
usage or to throw warnings
about strange logic constructs - much the same way as my PL/1 tool from
2007 did it (this was written in C).

If someone is interested, I will share the Pascal source of the COBOL
source code formatter ... contact me offlline.
But you will need the New Stanford Compiler to use it (available from
GitHub and from the WebSite above).

Kind regards

Bernd



Am 07.06.2020 um 02:26 schrieb Seymour J Metz:
> https://secure-web.cisco.com/1Ly5ugowEV6ot4gbUyw07wld8pVo5RD7yYuLNdHEOf-3il63S7RNh5Uhz3z3qoKCTFZWHjCdAd9NWtRND2NeuvtUodK8xswKDI8qCbark0s6SJ5nXm7-R2ftSd_nYVROosKE8L-PHT1wEeBiCnX_EoOBsN2JcXxfXFq_MNEEfAfs5I_hk6jaQfOdPfRC6_TLwm_g1xb0iM3ICYM0c8XPwUqrA4rLqXyfU-rIz4Dp8LJp_b5--XwmHIh5kl8_oQTbAGn4lksD2k0ehk9-HzYrQGjendQbb39rTwPrLGGng14e9Sx46KhwhyhYMz-stXs2kjIore_VyCD4j1FFWmlNBTVSYtOHijv6gCOsLEv9maQADfq2W7D_-_-XYWu4mAPz3Wu3h15kosqbDyPRuDf-xcCtA_dJ3oB55h5QETpelVe2_CuvHD-y2_nREcy5rpp4t/https%3A%2F%2Fwww.cs.sjsu.edu%2F%7Emak%2FCS185C%2FKnuthStructuredProgrammingGoTo.pdf
>
>
> --
> Shmuel (Seymour J.) Metz
> http://mason.gmu.edu/~smetz3

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to