PL/I preprocessor: Difference between revisions

Content deleted Content added
Evolution: %THEN and %ELSE
 
(4 intermediate revisions by 4 users not shown)
Line 68:
 
==Example==
The following example for IBM PL/I for OS/2 illustrates the use of a preprocessor procedure to implement a C-like write statement for PL/I.<ref>{{cite web|last=Sturm|first=Eberhard|title=UIO-Makros für Builtin-Funktionen fileread und filewrite|url=httphttps://www.uni-muenster.de/ZIV.EberhardSturm/uio.cpy|accessdateaccess-date=January 22, 2012}}</ref> The procedure would be called by coding the statement {{code|uwrite file(filename) from(varying_string) count(byte_count);}} {{mono|<var>Byte_count</var>}} is optional and defaults to the length of {{mono|<var>varying_string</var>}} if omitted.
<sourcesyntaxhighlight lang="rexx" line highlight="1,25,26">
%uwrite:
procedure keys (File, From, Count);
Line 96:
%end;
%act uwrite;
</syntaxhighlight>
</source>
 
The statement {{code|uwrite file(file_name) from(var_str) count(64);}} generates the following:
<sourcesyntaxhighlight lang="rexx">
do;
dcl Count00001 fixed bin (15);
Count00001 = filewrite(file_name, ptradd(addr(var_str), 2), min(length(var_str), 64));
end;
</syntaxhighlight>
</source>
 
==Evolution==
Line 129:
* <code>RETURN</code> in a compile-time procedure only.
* <code>%INCLUDE</code>
* <code>%IF</code> &ndash; the <code>%IF <var>compile_time_comparison</var> %THEN <var>unit</var> [%ELSE <var>unit</var>]</code> was restored.
 
A single compile-time builtin, <code>SUBSTR</code>, was added.
Also in 1966 Robert Rosin published a pair of articles<ref>{{cite journal|last=Rosin|first=Robert|title=PL/I Macro Processor - Progress Report|journal=PL/I Bulletin|date=August 1966|issue=2|url=http://www.iron-spring.com/PLI_Bulletins/PLI_Bulletin_2.pdf|accessdateaccess-date=January 22, 2013}}</ref><ref>{{cite journal|last=Rosin|first=Robert|title=Macros in PL/I|journal=PL/I Bulletin|date=August 1966|issue=2|url=http://www.iron-spring.com/PLI_Bulletins/PLI_Bulletin_2.pdf|accessdateaccess-date=January 22, 2013}}</ref> discussing development of the preprocessor. This development was based in a "[[SHARE (computing)|SHARE]] XXVI Memo" from earlier the same year and a paper by Mark Elson. Rosin credits [[MAD (programming language)|MAD]] as the only previous example of a macro processor in a high-level language.
 
==See also==
Line 143:
==External links==
*{{cite web
|url = http://publibfp.boulder.ibm.com/cgi-binepubs/bookmgr/BOOKSpdf/ibm3lr80/21.0?DT=20091014225516pdf
|title = Enterprise PL/I Language Reference (SC27-1460-09): Chapter 21. Preprocessor Facilities
|author = IBM Corporation
|date = October 2009
|accessdateaccess-date = Jan 19, 2012
}}
 
Line 155:
|author = Micro Focus International plc
|year = 2011
|accessdateaccess-date = Feb 14, 2012
}}
 
Line 163:
|author = Kednos Enterprises
|year = 2007
|accessdateaccess-date = Feb 14, 2012
}}
 
Line 171:
|author = Peter Flass
| year = 2010
|accessdateaccess-date = 2017-12-06
}} Comparison of preprocessor features