A bit off topic perhaps, but COBOL now supports the following: EXIT PERFORM (like LEAVE) EXIT PERFORM CYCLE (like ITERATE) EXIT PARAGRAPH (like LEAVE but exists the current COBOL paragraph) EXIT SECTION (like LEAVE but exists the current COBOL section)
You can even exit from a simple block, which you mentioned REXX does not support: PERFORM DISPLAY 'SOMETHING' IF A = 1 EXIT PERFORM END-IF DISPLAY 'SOMETHING ELSE' END-PERFORM One thing missing is an "infinite loop" (do forever). I have requested support of "PERFORM UNTIL EXIT" to allow for this. Feel free to vote for my RFE! https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=133631 ________________________________ From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> on behalf of Bob Bridges <robhbrid...@gmail.com> Sent: Tuesday, March 24, 2020 9:19 AM To: IBM-MAIN@LISTSERV.UA.EDU <IBM-MAIN@LISTSERV.UA.EDU> Subject: GOTOs (was CLIST) There is such a thing as overdoing GOTOs, but I agree that a blanket never-do-it rule is counter-productive. I don't often use SIGNAL in REXX, because I find that its structured features are adequate. But in other languages I have argued for limited GOTO use. In COBOL, for example, it seems to me that there's a place for GOTO TOP-OF-PARAGRAPH (to simulate ITERATE in REXX), GOTO EXIT-PARAGRAPH (to simulate LEAVE) and GOTO END-OF-PROGRAM (for controlled abend conditions). These don't violate structured-programming principles, they implement them. In VBA I freely use Goto IterateSomething (putting the label just before the Next statement). I don't think PL/1 ever needs it, but I'm glad it's there just in case. Even in REXX there's one missing structured ingredient: some way to leave a ~simple~ block. A SELECT comes close, but it's not perfect. Say you're looping through a list of candidates and have to perform a number of candidates: do jr=1 to stem.0 v0=stem.jr if v0='' then iterate v1=function1(v0) if v1<5 then iterate v2=functionv2(v1 + othervalue) if v2=previous then iterate say 'TRK:' v0 v1 v2 end That's great in a controled DO loop. But it's harder in simple block of code. A SELECT won't do the job, because of the calculations you have to do between the various tests. I handle it this way: do 1 if v0='' then leave v1=function1(v0) if v1<5 then leave v2=functionv2(v1+othervalue) if v2=previous then leave say 'TRK:' v0 v1 v2 end I always suspect I'd get complaints from structured enthusiasts if they ever saw me cheating like that. In VBA I can't "Do 1", but I can do this: Do 'one time If v0 = '' Then Exit Do v1 = function1(v0) If v1 < 5 Then Exit Do v2 = functionv2(v1 + othervalue) If v2 = previous Then Exit Do MsgBox "TRK: " & v0 & " " & v1 & " " & v2 Loop Until True --- Bob Bridges, robhbrid...@gmail.com, cell 336 382-7313 /* Being famous has its benefits, but fame isn't one of them. -Larry Wall */ -----Original Message----- From: David Crayford Sent: Tuesday, March 24, 2020 09:03 If you eschew goto how do you deal with error handling and cleanup using a language which doesn't support exceptions, finalization or RAII? I find these kind of blanket rules to lead to bad code with deep nesting and useless status variables. --- On 2020-03-21 11:45 PM, Paul Gilmartin wrote: > o Symbols EXPOSEd from external scopes can't be used as targets > of ITERATE and LEAVE. (I eschew GOTO; SIGNAL is worse,) ---------------------------------------------------------------------- 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