short circuit evaluation

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

short circuit evaluation

Postby Tzadik Vanderhoof » Fri Nov 30, 2007 10:56 pm

I noticed (quite by accident) that the Cobol I'm using has "short-circuit logic evaluation". For example, you can do:

without worrying about making a reference outside the bounds of the table. If IDX is greater than MAX-IDX, the code will not even execute the part after the AND. I knew C and Java had this feature but it quite useful to know that COBOL also has it.

The way I discovered this was that I had the 2 sides of the AND reversed, so it was ABENDING due an out-of-table reference, even though I was checking for that... I was just checking it in the wrong order. Switching the order solved it.

Does anyone know if that is part of the standard, or is it just an added feature of certain versions?
Tzadik Vanderhoof
Posts: 21
Joined: Tue Nov 13, 2007 11:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: short circuit evaluation


Re: short circuit evaluation

Postby dick scherrer » Sat Dec 01, 2007 1:12 am


Look at the documentation for SSRANGE.
Hope this helps,
User avatar
dick scherrer
Global moderator
Posts: 6308
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 90 times

Return to IBM Cobol


  • Related topics
    Last post