IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Composite symbols in PL/I preprocessor procedures


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
ppleva

New User


Joined: 10 Dec 2007
Posts: 7
Location: Czech Republic

PostPosted: Thu Nov 19, 2009 3:07 pm
Reply with quote

Hi all!

PL/I allows using composite symbols (e.g. += or -=) within source, which is well described (Language Reference - Program Elements - Single-Byte Character Set - Composite symbols).

Such symbols aren't listed in Preprocessor Statements list (Language Reference - Preprocessor Facilities - Preprocessor Statements; especially under "%assignment Statement"), hence they should not be accepted by PL/I Preprocessor.

However Enerprise PL/I compilers (I'm sure about "IBM(R) Enterprise PL/I for z/OS V3.R2.M0" and newer) accept such code! I don't complain icon_smile.gif, but the question is: Where is this behavior described/documented? (I've googled for hours and didn't find anything icon_sad.gif.)

Code sample:
Code:

 %CSPROC: PROCEDURE;
     DCL I FIXED;
     I = 0;
     I += 1;
 %END;
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Nov 19, 2009 3:24 pm
Reply with quote

Enterprise PL/I for z/OS SC27-1460
Back to top
View user's profile Send private message
ppleva

New User


Joined: 10 Dec 2007
Posts: 7
Location: Czech Republic

PostPosted: Thu Nov 19, 2009 5:30 pm
Reply with quote

Peter, thanks for response. Of course I've read Enterprise PL/I for z/OS Language Reference, even the latest one (V3R9), that's where I've started before I post to this forum icon_exclaim.gif
However I don't see the answer there (in my original post I wrote where I was looking for it). Could you please be so kind and direct me to the particular chapter/page?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Nov 19, 2009 6:12 pm
Reply with quote

I clicked on the manuals link at the top of the page, pulled up the PL/I Language Reference manual, clicked on the Search icon, typed in += and did the search, and found chapter 9.2.2 Compound Assignment Statement as the second found page. This took less than two minutes, total. Perhaps instead of Googling, you should just go to the manual and use that as your starting point?
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Nov 19, 2009 6:16 pm
Reply with quote

ppleva

you can download the pdf from here :

www-01.ibm.com/software/awdtools/pli/plizos/library/

Enterprise PL/I for z/OS SC27-1460-09

After that open the pdf and do a search for composite.

Its not a behavior, its a part of this language.
Back to top
View user's profile Send private message
ppleva

New User


Joined: 10 Dec 2007
Posts: 7
Location: Czech Republic

PostPosted: Thu Nov 19, 2009 8:51 pm
Reply with quote

I've read the manual. I know what are composite symbols, I know how compound assignment statements look like. I know that "i+=1;" is correct PL/I statement, but I'm asking about PL/I Preprocessor statements (look at the code sample in my original post) icon_exclaim.gif


In another words:

A. I've verified that IBM Enterprise PL/I for z/OS V3.R2.M0 (and newer) compiler accepts compound assignment statement within preprocessor procedure.

B. In SC27-1460-09, Chapter 21. "Preprocessor Facilities", section "Preprocessor Statements" there is paragraph "%assignment Statement". In there I see a sentence: Compound and multiple assignments are not allowed.

I see a contradiction between statements A and B. Is this documented somewhere?
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Nov 19, 2009 11:28 pm
Reply with quote

What the <hell> do you want to know?

Its there for you to use.

Am im getting psychic too?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Nov 19, 2009 11:45 pm
Reply with quote

You don't understand the manual, for starters. The %assignment specifically states compound and multiple assignments are not allowed. However, if you read the syntax diagram on that very same page, you will note that it is referring to preprocessor variables, and only preprocessor variables. What is a preprocessor variable? From section 21.3 of the manual,
Quote:
A preprocessor variable is specified in a %DECLARE statement with either the FIXED or the CHARACTER attribute.

The code you posted in the original post has no preprocessor variables, so the %assignment restriction does not apply. You may place compound or multiple assignment statements that do not use the preprocessor facilities anywhere you want, including in preprocessor code.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Fri Nov 20, 2009 12:04 am
Reply with quote

if You are not satisfied or You find that there are <errors> with/in the IBM documentation
use the Readers' Comments at the end of the manual to send comments/feedback by snail mail
or search the IBM site on how to submit the same by electronic means

while the use of compound assignment statements in real code might, repeat MIGHT, yield some optimization advantages
( hard to believe...
it would be wise to look at the generated assembler code to check
I checked for C and there is no difference in the generated code ... i+=1; vs. i=i+1; )

<frankly> I do not see any advantage in using it in the preprocessor stage for preprocessor entities
( it adds useless clutter/complexity to the the preprocessor scanner/parser,
and the whole thing is being interpreted anyways )

but on the other side I do not see any issue in using it in the <generated> statements
maybe that' s what You see
and that' s what happened in the snippet You posted...
the three statements are just copied as is
they are not preprocessor's statements

anyway looks like that some of us have on the subject the same feelings as Rhett Butler
Back to top
View user's profile Send private message
ppleva

New User


Joined: 10 Dec 2007
Posts: 7
Location: Czech Republic

PostPosted: Fri Nov 20, 2009 2:23 pm
Reply with quote

Robert Sample & enrico-sorichetti, thanks for very detailed answer, I appreciate it.

I was confused by manual section 21.6 saying:
Quote:
Preprocessor statements in a preprocessor procedure do not begin with a percent symbol.

Hence I thought: icon_arrow.gif "DCL" (without %) is a preprocessor statement because it appears in a preprocesor procedure icon_arrow.gif Then variable "I" in my sample is preprocessor variable icon_arrow.gif If "I" is preprocessor variable it is not allowed in compound assignment statement.

However if "I += 1;" in my sample code is NOT preprocessor statement, then everything is clear. (Still I thought it is because (according to my weak PL/I knowledge) it seems to be evaluated in preprocessor step - see listing further.)


I admit my example with "I" might not be quite obvious... So what do you say about this example with "J"? Why this (line 18.1) works? (I'd expect something like "IEL0080I S 18 INVALID TEXT IGNORED FROM 'J' TO SEMICOLON." which I get with older compiler.)
Code:

15655-H31  IBM(R) Enterprise PL/I for z/OS       V3.R2.M0 (Built:20031007)
- MACRO Source
0  Line.File
0     2.1      SAMP: PROC OPTIONS(MAIN);
      3.1
      4.1      %DCL J FIXED;    /* preprocessor variable */
      5.1      %J = 0;
      6.1      %CSPROC: PROCEDURE RETURNS (CHAR);
      7.1          DCL I FIXED; /* preprocessor variable too (?) */
      8.1          I = 0;
      9.1          I += 1;
     10.1          IF I = 1 THEN RETURN ('PUT SKIP LIST (''I=1'');');
     11.1          ELSE RETURN ('PUT SKIP LIST (''I<>1'');');
     12.1      %END;
     13.1
     14.1      %ACTIVATE CSPROC;
     15.1          CSPROC
     16.1      %DEACTIVATE CSPROC;
     17.1
     18.1      %J += 5;
     19.1      IF J = 5 THEN PUT SKIP LIST ('J = 5');
     20.1      END SAMP;

15655-H31  IBM(R) Enterprise PL/I for z/OS       SAMP: PROC OPTIONS(MAIN)
0 Compiler Source
0  Line.File
0     2.1      SAMP: PROC OPTIONS(MAIN);
      3.1
     15.1          PUT SKIP LIST ('I=1');
     15.1
     19.1      IF        5 = 5 THEN PUT SKIP LIST ('J = 5');
     20.1      END SAMP;

15655-H31  IBM(R) Enterprise PL/I for z/OS       SAMP: PROC OPTIONS(MAIN)
- Compiler Messages
0 Message     Line.File  Message Description
0 IBM1114I W    19.1     Comparands are both constant.
  IBM1043I I    19.1     SYSPRINT is contextually declared as FILE.
- Component    Return Code    Messages (Total/Suppressed)    Time
0 MACRO            0                0  /  0                   0 secs
  Compiler         4                2  /  0                   1 secs
0 End of compilation of SAMP
Back to top
View user's profile Send private message
ppleva

New User


Joined: 10 Dec 2007
Posts: 7
Location: Czech Republic

PostPosted: Fri Nov 20, 2009 2:28 pm
Reply with quote

PeterHolland wrote:
What the <hell> do you want to know?

I'm asking why PL/I compiler accepts something what is forbidden in PL/I language reference. And I'm asking where this should be documented. (I was thinking about this being a new feature which they forgot to mention in manual?)

PeterHolland wrote:
Am im getting psychic too?

I don't know, what do you think? icon_lol.gif
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1315
Location: Vilnius, Lithuania

PostPosted: Fri Nov 20, 2009 3:08 pm
Reply with quote

ppleva wrote:
PeterHolland wrote:
What the <hell> do you want to know?

I'm asking why PL/I compiler accepts something what is forbidden in PL/I language reference. And I'm asking where this should be documented. (I was thinking about this being a new feature which they forgot to mention in manual?)

PeterHolland wrote:
Am im getting psychic too?

I don't know, what do you think? icon_lol.gif


Please put this on the PL/I mailing list, which is read by IBM's head of PL/I development, Peter Elderon. He is the only authoritative source with regards to IBM PL/I standards.

Discussing this matter here is just a waste of time.

And if you want to go completely ape-shit the fact that PL/I has OO extensions is also not mentioned in the manual... And older versions of PL/I already had undocumented builtin functions.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Fri Nov 20, 2009 5:47 pm
Reply with quote

Unlike your original post, at this point you have definitely identified what appears to be a discrepancy between compiler behavior and the documentation (there still could be an interpretation problem but if so then IBM needs to address that so either way there's an issue for IBM). The only source for an answer will be someone at IBM.
Back to top
View user's profile Send private message
ppleva

New User


Joined: 10 Dec 2007
Posts: 7
Location: Czech Republic

PostPosted: Fri Nov 20, 2009 9:43 pm
Reply with quote

Thanks for answers. I think this topic can be closed now.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Fri Nov 20, 2009 9:52 pm
Reply with quote

We would be interested to hear what you learn from IBM icon_smile.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts XL C Trace Preprocessor Output All Other Mainframe Topics 3
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts Infosphere Optim - unable to save Col... IBM Tools 0
No new posts user exits in Column Map procedures IBM Tools 0
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
Search our Forums:

Back to Top