Space is permitted almost everywhere in PL/1,
not in the middle of identifiers (in contrast to FORTRAN).
It is permitted before the left paranthesis of subscripts,
so there is no chance for the compiler to decide before
the semicolon or THEN in this case:
IF (possible index expr1) = (complicated and long expr2); /* valid
assignment */
IF (possible index expr1) = (complicated and long expr2) THEN ... /* IF
statement */
This decision has to be done by the Parser, before if knows,
if there is a definition for a IF array. The problem for this
ambiguity is a problem of the PL/1 grammar. Pascal and other
languages avoid this by defining different symbols for
comparison and assignment.
Furthermore: the more modern languages like Pascal, C and Java etc.
forbid the use of reserved symbols as variable names. This may be
restrictive, but makes the compilers much much simpler.
Kind regards
Bernd
Am 16.07.2019 um 20:37 schrieb Seymour J Metz:
AFAIK a space is not permitted in PL/I between an identifier and the left
parenthesis for the subscripts. If that is correct then
IF (1) = (2);
can easily be recognized as an IF statement.
Id do, however, agree that it is very bad form to knowingly use a keyword as an
identifier.
--
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: Tuesday, July 16, 2019 2:22 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Where put the notional constant in a condition (Was RE: JCL COND
Parameter)
This double meaning of =, together with the absence of reserved words
makes PL/1 parsing extremely hard. Consider for example
IF (1) = (2);
now what does that mean?
Given a declaration
DCL IF (25) BIN FIXED (31);
that is, if IF is an array of integers, the "IF" statement above is a
valid assignment
of 2 to the array element 1. The PL/1 compiler does not know that the
statement
above is no IF statement before it encounters the semicolon; before that
it has
to consider both possibilities ... this is completely different from
most other
languages (only Fortran has similar issues).
I always thought that nobody would be as silly as to name his or her
identifiers IF,
but then I observed a program containing the following:
DCL IA BIN FIXED (15) /* index for TABA */
DCL IB BIN FIXED (15) /* index for TABB */
DCL IC BIN FIXED (15) /* index for TABC */
DCL ID BIN FIXED (15) /* index for TABD */
DCL IE BIN FIXED (15) /* index for TABE */
DCL IF BIN FIXED (15) /* index for TABF */
the coder probably didn't even notice the use of IF as variable name :-))
Long live PL/1 :-)))
Kind regards
Bernd
Am 16.07.2019 um 20:04 schrieb Seymour J Metz:
One of the things that I liked about Algol was that "=" was always a comparison operator; assignment was
":=". But even in PL/I that particular error is impossible: the "=" in "IF foo=bar" can
never be interpreted as assignment.
--
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
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN