BIT(1) and BINARY are two different things in PL/I. The coercion of bit strings 
into FIXED BINARY looked good at the time, but I believe that it was a bad 
decision, as your example shows. OTOH, it's even worse to treat numerical or 
character data as boolean.


--
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: Friday, June 5, 2020 7:34 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: COBOL Question

This triggered me once more, sorry :-)

I recall that we once did a larger project, checking all the PL/1 sources
at a customer of mine, looking for errors in program logic, using a tool
that I wrote (sort of a light weight, yet powerful, PL/1 parser).

The parser threw errors (observations) on about ten percent of the
source codes.

One program had this coding:

IF 9 < ZZ < 20 THEN DO;

no error from the compiler, no warning :-)

the condition turned out to be always true, because

(9 < ZZ) < 20

the left part is evaluated and gives a binary result (BIT(1) in PL/1
speech);
this is converted to decimal, and no matter what the value of ZZ is,
the BIT(1) is always lower than 20 (be it '0'B or '1'B).

This was of course not what the author intended; this was at an insurance
company where most of the programmers had a math background, so this
kind of expression was natural to them. The compiler didn't complain.

Kind regards

Bernd


Am 05.06.2020 um 23:26 schrieb Paul Gilmartin:
> On Fri, 5 Jun 2020 20:54:37 +0000, Seymour J Metz wrote:
>
>> SMOD (IND1) = 'B' OR 'R' means (SMOD (IND1) = 'B') OR (SMOD (IND1) = 'R'); 
>> syntax for implied comparands exists in other languages as well.
>>
> I have dealt with a language (Mainsail) that had a ternary compare:
>      A <= B < C
> I don't know whether it avoided side effects of evaluating B twice.
> It probably (I'm not sure) short-circuited to avoid evaluating C
> needlessly.
>
> I like semi-open intervals, especially in loops.
>
> -- gil
>
> ----------------------------------------------------------------------
> 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

----------------------------------------------------------------------
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