79652447

Date: 2025-06-04 09:13:13
Score: 0.5
Natty:
Report link

A bit late, label1 contains a section clause while label2, label3, and label4 do not. This means that if one performs label1 then label2, label3, and label4 will also be executed. Even if label1 exits early label2, label3, and label4 will still be performed.

Some mainframe shops prohibit the use of sections because because of this follow through effect if a section header is missing in a following paragraph(s). In your example, if you don't want to execute label2 when label1 is exited early then code an exit-section rather than an exit-paragraph.

Again in your example it is better to have label1 perform label2 than perform label2 as part of a section.

Also, "perform thru "is an old constrict which was needed if a go to exit statement was coded. Newer versions of COBOL have the exit-paragraph (and exit-section) directive which will terminate a performed paragraph or section early thereby eliminating the need for a perform through, a go to statement and an exit paragraph completely.

it is better to code multiple performs (perform label1 followed by perform lanel2) than perform label1 through label3 since it is easier to see "upfront" what will be performed rather than looking at the performed paragraphs to see what is being performed and if any other paragraphs exist between label1 and label2.

If the individual paragraphs were coded as label2, label2, and label3 then a perform label1 through label3 would also result in label2 being performed.

Bottom line, don't use sections, go to, and exit paragraphs but explicitly code only the paragraphs which are desired.

FWIW, I still code an exit paragraph containing only an exit statement after each paragraph to serve only as a STOP sign to any PERSON reading the code and remind them that each paragraph is a "stand alone" entity with a single entry and exit point and no following paragraphs will be executed.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: D.G.Lang