| Related articles |
|---|
| From: | "Robin Vowels" <robin51@dodo.com.au> |
| Newsgroups: | comp.compilers |
| Date: | Mon, 3 Oct 2022 12:34:14 +1100 |
| Organization: | Compilers Central |
| References: | 22-09-026 22-10-002 22-10-004 |
| Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="242"; mail-complaints-to="abuse@iecc.com" |
| Keywords: | PL/I, history, comment |
| Posted-Date: | 02 Oct 2022 21:56:32 EDT |
From: "gah4" <gah4@u.washington.edu>
Sent: Sunday, October 02, 2022 11:05 AM
> On the other hand, PL/I is pretty good at allowing things, even if
> there isn't much reason. I did this one in high school, not knowing
> if it would actually work:
>
> DCL (I, J, K, L) CHAR(100);
> J='1';
> K='100';
> L='1';
> DO I=J TO K BY L;
> PUT LIST(I, SQRT(I));
> END;
>
> I suspect no designers of PL/I ever expected someone to try it,
> but the ability is there, and compilers do it.
>
> Now, it turns out that you have to add a few blanks to K, as the
> loop comparison is done as a string compare. (I didn't guess
> that until finding that the loop didn't end.)
>
> C lets you do some things that it probably shouldn't, though.
>
> Unlike many languages, the whole definition of PL/I was written
> before writing the first compiler.
That's not true. The preprocessor was designed after the first
release. As well as that, some features of output were designed after
the first release.
> (Not that all features were implemented in the first compiler.)
> [PL/I was a remarkably good language considering what a rush job it was but
> it has plenty of odd things, e.g.
>
> DCL (I, J, K) CHAR(3);
> I = 1;
> J = 2;
> K = I+J;
This will not work either.
In the first place, the lengths of the strings are too small to accommodate
the converted integer constants, 1 and 2. The STRINGSIZE condition is raised
at run-time.
In the second place, the length of K is too short to accommodate
the sum of I and J.
In the third place, the STRINGSIZE condition is raised at run-time
for the assignments to I, J, and K.
Apart from that, the compiler gives compile-time messages that,
in each of the three assignments, the string variables are too short to
accommodate the values that are to be assigned to them.
> What does K contain? Nope, it contains three spaces because the 1 and 2
> are converted to ' 1' and ' 2', they're converted back to integer,
> added, converted back to to a default size integer string
> like ' 3' and string assignment truncates from the right. -John]
Again, not quite. Even if such a program were allowed to run,
the STRINGSIZE condition is raised. What happens after that depends on
what the programmer does to handle the condition.
[The IBM manuals say that STRINGSIZE is normally disabled. So you
can check for truncation if you want, but by default it won't
and you'll get the three spaces. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.