PL/I language
Designed to serve scientific, commercial, real-time and systems programmers in one language: ALGOL block structure, COBOL-style records and picture editing, FORTRAN arithmetic, storage classes and ON-units. Multics was written in it.
Overview
PL/I is a procedural, imperative language designed by IBM and a SHARE committee so one language could serve scientific, commercial and systems programmers. It combined ALGOL block structure with COBOL-style records and picture editing, FORTRAN arithmetic, programmer-controlled storage classes and ON-unit exception handling.
Code
hello: proc options(main);
dcl n fixed binary(31) init(42);
dcl msg char(20) varying;
dcl flags bit(8) aligned init('10101010'b);
dcl rate fixed decimal(5,2) init(0.05);
msg = 'total: ' || char(n);
put skip list(msg, n * 2, rate, flags);
end hello;
invoice_report: proc options(main);
dcl 1 invoice,
2 customer char(12) varying,
2 total fixed decimal(9,2) init(0),
2 qty(5) fixed binary(15);
dcl items(3) char(8) init('nut','bolt','washer');
dcl i fixed binary(15);
do i = 1 to 5;
invoice.qty(i) = i * 10;
invoice.total = invoice.total + invoice.qty(i);
end;
put skip list(invoice.total, invoice.qty(3), items(2));
end invoice_report;
report: proc options(main);
sum_to: procedure(limit) returns(fixed binary(31));
dcl (limit, i, acc) fixed binary(31);
acc = 0;
do i = 1 to limit;
acc = acc + i;
end;
return(acc);
end sum_to;
put skip list(sum_to(10));
end report;
demo: proc options(main);
dcl buffer(100) fixed binary(31) controlled;
on condition(overdraft) put skip list('limit exceeded');
allocate buffer;
buffer(1) = 42;
if buffer(1) > 40 then signal condition(overdraft);
free buffer;
end demo;
dcl fixes base, scale, length and storage class at once, so controlled puts
the buffer's lifetime under allocate/free,
while the on condition
unit registered earlier handles the condition signal raises.Distinctive traits
- Storage classes (
static,automatic,controlled,based,area) make lifetime a declaration;controlled,basedandareaput allocation underallocate/free. - No reserved words:
keywords are ordinary identifiers, so later additions such as
selector packages could not invalidate working programs. - ON-units
attach an exception handler to each runtime condition (
zerodivide,conversion,endfile) and are inherited down the call chain. - PICTURE and FIXED DECIMAL give COBOL-style report editing and packed-decimal data in the same syntax as binary arithmetic.
- Multitasking is in the language: TASK and EVENT variables, a task option on
call, and awaitjoin (fork/join). - Bit strings and pointer-addressed
basedvariables let system code lay out and walk control blocks from a high-level language.
Status
Active. IBM Enterprise PL/I for z/OS 6.2 is the current mainframe compiler, Iron Spring PL/I covers Linux and OS/2, and the language is standardized as ISO 6160:1979 (endorsing ANSI X3.53-1976) and ECMA-50.
History
SHARE's Advanced Language Development Committee was charged by SHARE and IBM to specify a language serving scientific, commercial, real-time and systems programmers; its first definition appeared as the NPL Technical Report in December 1964. MIT's Multics project wrote a system-programming subset, EPL, and then the operating system itself in PL/I. ANSI standardized the language in 1976 (X3.53), ECMA in 1976 (ECMA-50) and ISO in 1979 (ISO 6160).
Sources & references
- Official siteibm.com
- ECMA-50 — Programming Language PL/I, 1st edition (December 1976)ecma-international.org
- ISO 6160:1979 — Programming languages: PL/I (endorsement of ANSI X3.53-1976)iso.org
- Enterprise PL/I for z/OS 6.2 — Language Reference (IBM)ibm.com
- Open PL/I — Chapter 4: Declarations and Attributes (Micro Focus)microfocus.com
- Open PL/I — Chapter 8: Statements (Micro Focus)microfocus.com
- The Choice of PL/I — Multics history, by McIlroy, Van Vleck, Mills, Freiburghouse et al.multicians.org
- NPL Technical Report (IBM, December 1964) — the language's first definition, archivedweb.archive.org
- NPL: Highlights of a New Programming Language — Radin and Rogoway, Communications of the ACM 8(1), 1965dl.acm.org