View previous topic :: View next topic
|
Author |
Message |
Sakthidevi
New User
Joined: 15 Nov 2019 Posts: 7 Location: India
|
|
|
|
Hi,
Is the below syntax valid in PL/I?
DCL A CHAR(10),
B LIKE A,
C LIKE B,
D LIKE C;
This was asked as an interview question. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
The PL/I Language Reference manual has this example:
Quote: |
The following declarations are valid, but only because B is declared before C and E is declared before F:
dcl 1 a, 2 a1 fixed bin;
dcl 1 b, 2 b1 like a;
dcl 1 c, 2 c1 like b;
dcl 1 d, 2 d1 fixed bin;
dcl 1 e like d;
|
So it appears the interview question's declarations are valid, but I don't have access to a PL/I compiler to verify that. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Why didn't you look it up in the manual, after the interview?
It may be allowed nowadays, but it wasn't in earlier versions of PL/I (including Enterprise PL/I), and I have my doubts about using like for elementary variables. |
|
Back to top |
|
|
Sakthidevi
New User
Joined: 15 Nov 2019 Posts: 7 Location: India
|
|
|
|
Thanks Robert!
I have 13 years of experience in mainframe and currently looking for a change.
Never have seen such a logic. Do people do something as bad as that? |
|
Back to top |
|
|
|