Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
PL/I
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Language summary== The language is designed to provide sufficient facilities to be able to satisfy the needs of all programmers, regardless of what problems the language is being applied to.<ref>{{cite book|last1=Vowels|first1=Robin |title=Introduction to PL/I |year=2001|isbn=978-0-9596384-9-3|page=x|publisher=R.A. Vowels |quote="PL/I is the first language to provide adequate facilities for scientific computations, business data processing and systems programming in a single language" - [[Jean Sammet]], ''Some Approaches to, and Illustrations of, Programming Language History''}}</ref> The summary is extracted from the ANSI PL/I Standard<ref name="ReferenceA">ANS Programming Language PL/I. X3.53-1976</ref> and the ANSI PL/I General-Purpose Subset Standard.<ref name="SubsetG" /> A PL/I program consists of a set of procedures, each of which is written as a sequence of statements. The <code>%INCLUDE</code> construct is used to include text from other sources during program translation. All of the statement types are summarized here in groupings which give an overview of the language (the Standard uses this organization). {| |- style="vertical-align:top" | {| class="wikitable" |- ! Category ! Statement |- | Structural | <code>PROCEDURE</code> (or <code>PROC</code>)<br/> <code>ENTRY</code><br/> <code>BEGIN</code><br/> <code>DO</code><br/> <code>END</code> |- | Declarative | <code>DECLARE</code> (or <code>DCL</code>)<br/> <code>DEFAULT</code> (or <code>DFT</code>)<br/> <code>FORMAT</code> |- | Flow of control | <code>CALL</code><br/> <code>IF</code><br/> <code>SELECT</code><br/><code>GO TO</code><br/> <code>RETURN</code><br/> <code>STOP</code><br/> Null statement |- |} | {| class="wikitable" |- ! Category ! Statement |- | Interrupt handling | <code>ON</code><br/> <code>SIGNAL</code><br/> <code>REVERT</code> |- | Storage | <code>ALLOCATE</code> (or <code>ALLOC</code>)<br/> <code>FREE</code><br/> Assignment statement |- | Input/Output | <code>OPEN</code><br/> <code>CLOSE</code> |- | Stream input/output | <code>GET</code><br/> <code>PUT</code> |- | Record input/output | <code>READ</code><br/> <code>WRITE</code><br/> <code>REWRITE</code><br/> <code>LOCATE</code><br/> <code>DELETE</code> |} |} (Features such as [[Computer multitasking|multi-tasking]] and the [[PL/I preprocessor]] are not in the Standard but are supported in the PL/I F compiler and some other implementations are discussed in the Language evolution section.) Names may be declared to represent data of the following types, either as single values, or as aggregates in the form of arrays, with a lower-bound and upper-bound per dimension, or structures (comprising nested structure, array and scalar variables): {| | * <code>Arithmetic</code> (expanded below) * <code>CHARACTER</code> * <code>PICTURE for Arithmetic data</code> * <code>PICTURE for Character data</code> | * <code>AREA</code> * <code>BIT</code> * <code>ENTRY</code> * <code>FILE</code> | * <code>FORMAT</code> * <code>LABEL</code> * <code>OFFSET</code> * <code>POINTER</code> |} The <code>arithmetic</code> type comprises these attributes: {| | * a base (<code>BINARY</code> or <code>DECIMAL</code>), and * a scale (<code>FIXED</code> or <code>FLOAT</code>), and * a mode (<code>REAL</code> or <code>COMPLEX</code>), and * a <code>PRECISION</code> (<code>number of digits</code>, and for fixed point numbers, a <code>scale factor</code>) |} The base, scale, precision and [[scale factor]] of the <code>Picture-for-arithmetic</code> type is encoded within the <code>picture-specification</code>. The mode is specified separately, with the <code>picture specification</code> applied to both the real and the imaginary parts. Values are computed by expressions written using a specific set of operations and builtin functions, most of which may be applied to aggregates as well as to single values, together with user-defined procedures which, likewise, may operate on and return aggregate as well as single values. The assignment statement assigns values to one or more variables. There are no reserved words in PL/I. A statement is terminated by a semi-colon. The maximum length of a statement is implementation defined. A comment may appear anywhere in a program where a space is permitted and is preceded by the characters forward slash, asterisk and is terminated by the characters asterisk, forward slash (i.e. {{code|/* This is a comment. */}}). Statements may have a label-prefix introducing an entry name (<code>ENTRY</code> and <code>PROCEDURE</code> statements) or label name, and a condition prefix enabling or disabling a computational condition{{snd}} e.g., <code>(NOSIZE)</code>). Entry and label names may be single identifiers or identifiers followed by a subscript list of constants (as in <code>L(12,2):A=0;</code>). A sequence of statements becomes a ''group'' when preceded by a <code>DO</code> statement and followed by an <code>END</code> statement. Groups may include nested groups and begin blocks. The <code>IF</code> statement specifies a group or a single statement as the <code>THEN</code> part and the <code>ELSE</code> part (see the sample program). The group is the unit of iteration. The begin ''block'' (<code>BEGIN; stmt-list END;</code>) may contain declarations for names and internal procedures local to the block. A ''procedure'' starts with a <code>PROCEDURE</code> statement and is terminated syntactically by an <code>END</code> statement. The body of a procedure is a sequence of blocks, groups, and statements and contains declarations for names and procedures local to the procedure or <code>EXTERNAL</code> to the procedure. An ''ON-unit'' is a single statement or block of statements written to be executed when one or more of these ''conditions'' occur: a ''computational condition'', {| | * <code>CONVERSION (CONV)</code> * <code>FIXEDOVERFLOW (FOFL)</code> * <code>OVERFLOW (OFL)</code> * <code>SIZE</code> | * <code>STRINGRANGE (STRG)</code> * <code>STRINGSIZE (STRZ)</code> * <code>SUBSCRIPTRANGE (SUBRG)</code> * <code>UNDERFLOW (UFL)</code> | * <code>ZERODIVIDE (ZDIV)</code> * * * |} or an ''Input/Output'' condition, {| | * <code>ENDFILE(file)</code> * <code>ENDPAGE(file)</code> * <code>KEY(file)</code> * <code>NAME(file)</code> | * <code>RECORD(file)</code> * <code>TRANSMIT(file)</code> * <code>UNDEFINEDFILE(file) (UNDF)</code> * |} or one of the conditions: *<code>AREA</code>, <code>CONDITION (identifier)</code>, <code>ERROR</code>, <code>FINISH</code> A declaration of an identifier may contain one or more of the following attributes (but they need to be mutually consistent): {| class="wikitable" |- ! Data attributes ! Input/output attributes ! Other attributes |- | <code>ALIGNED</code> | <code>DIRECT</code> | <code>AUTOMATIC or AUTO</code> |- | <code>AREA[(area-size)]</code> | <code>ENVIRONMENT(options) or ENV...</code> | <code>BASED[(reference)]</code> |- | <code>BINARY [(precision)] or BIN...</code> | <code>INPUT</code> | <code>BUILTIN</code> |- | <code>BIT [(maximum-length)]</code> | <code>KEYED</code> | <code>CONDITION or COND</code> |- | <code>CHARACTER[(maximum-length)] or CHAR...</code> | <code>OUTPUT</code> | <code>CONSTANT</code> |- | <code>COMPLEX [(precision)] or CPLX...</code> | <code>PRINT</code> | <code>CONTROLLED or CTL</code> |- | <code>DECIMAL [(precision)] or DEC...</code> | <code>SEQUENTIAL or SEQL</code> | <code>DEFINED[(reference)] or DEF...</code> |- | <code>(dimension-attribute)</code> | <code>STREAM</code> | <code>EXTERNAL or EXT</code> |- | <code>ENTRY[(parameter descriptor list]</code> | <code>UPDATE</code> | <code>GENERIC(criteria list)</code> |- | <code>FILE</code> | <code>RECORD</code> | <code>INITIAL(value-list) or INIT...</code> |- | <code>FIXED [(precision)]</code> | | <code>INTERNAL or INT</code> |- | <code>FLOAT [(number of digits)]</code> | | <code>LIKE unsubscripted reference</code> |- | <code>FORMAT</code> | | <code>LOCAL</code> |- | <code>LABEL</code> | | <code>OPTIONS(options)</code> |- | <code>MEMBER</code> | | <code>PARAMETER or PARM</code> |- | <code>NONVARYING or NONVAR</code> | | <code>POSITION [(expression)] or POS...</code> |- | <code>OFFSET[(reference)]</code> | | <code>STATIC</code> |- | <code>PICTURE picture-specification or PIC...</code> | | <code>VARIABLE</code> |- | <code>POINTER or PTR</code> | | |- | <code>STRUCTURE</code> | | |- | <code>UNALIGNED or UNAL</code> | | |- | <code>VARYING or VAR</code> | | |} Current compilers from [[Micro Focus]], and particularly that from IBM implement many extensions over the standardized version of the language. The IBM extensions are summarised in the Implementation sub-section for the compiler later. Although there are some extensions common to these compilers the lack of a current standard means that compatibility is not guaranteed.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)