PLACE
languages

CPL

CPL (Combined Programming Language) was being developed in the early and mid 1960s. It was based roughly on Algol 60, to which it made many important additions aiming at more general applicability. The language was meant to serve as a vehicle for research into both programming concepts and the design of compilers but, as it turns out, it has never been fully implemented. This is partly because of its size and complexity – both large by that time's measures – but perhaps most of all because its definition never became stable and written down in detail. The use of CPL stopped in the early 1970s.

At some point, the language BCPL was created as a reduced version of CPL in which it was expected to write a compiler for the bigger language. BCPL was strongly influential in the creation of C and thus some concepts of CPL affected the design of both these languages. Other languages, such as Pop-2, are also known to have borrowed from CPL. It can be surmised that the design of Algol 68 was influenced by CPL but whether that is true is unclear.

At present, there is little available information on CPL (see the links below).

Language Features

CPL's primitive data types include integer, real, complex, index (a variant of integer), as well as Boolean, logical (a bit sequence of some size), string, and label.

Worth mentioning is that, similarly to Algol 60, string constants are delimited with symmetric and rather than a pair of " which lack orientation. Regrettably, this is a rare property now.

Another lexical peculiarity of CPL is its distinguishing between small and large names of variables. A small name is a single lower-case letter, while a large one starts with an upper-case letter and may have a greater length. Multiplication of small letters can be written down implicitly, such as in a/bc. The latter is read as a/(b×c), because CPL implies that multiplication and division are, unlike most other languages, right-associative.

Composite data objects can be built using heterogeneous lists and arrays of arbitrary dimensionality. Each item of a list is an L-value, so that it is possible to assign to specific list items. Lists provide a structure mechanism that permits convenient handling of trees, directed graphs, and other structures.

The very distinction between L- and R-values of a program object, now well known from C, was introduced in CPL to help explain assignment, binding and other fundamental concepts.

CPL is rich in control constructs, especially repetitive ones. All of them are transferred almost identically to BCPL.

Expression-oriented style of programming is supported in CPL by providing conditional expressions and value-returning blocks. The syntax for conditional expressions is very close to the notation originally devised by J. McCarthy for Lisp. For a choice governed by a single or multiple condition, one would write b->e1,e2 and b1->e1,…bn->en,en+1, respectively, where the bs are Boolean expressions and the es are any expressions. A value-returning block has the form value of §…§ where the statement result is … has to be executed within the block. (See also BCPL in this respect.)

A command or an expression can be equipped with a where-clause providing local definitions, which can themselves be refined by other where clauses.

A definition of a variable can be accompanied by an initializing value, or the definition can be an identity (a feature later adopted in Algol 68). Multiple definitions can be performed simultaneously, so that they can refer to each other. Simultaneous assignments are also possible, as well as multiple assignments, as in all a,b,c := 0, or all A := 0 (A being an array).

Arguments can be passed to procedures in three different modes: by value, by substitution (corresponding to Algol 60's by name), and by reference. As procedures are first-class objects in CPL, one can program in it in a functional style. Free variables in procedures can be bound by either their R-values or their L-values, thus there are two kinds of procedure closures, both with lexical (static) binding.

Operators in CPL are permitted to be polymorphic. It is this language where the notions of parametric and ad hoc polymorphism first appeared.

A number of the concepts and constructs of CPL are a contribution of this very language to programming. Others were invented elsewhere, but CPL was the one that eventually brought attention to their value.

CPL was, in the 1960s, sufficiently advanced to support techniques of functional programming that would be considered modern even today. The following function computes the Cartesian product of a list of lists:

let Product[L] = Lit[f,List1[NIL],L]
  where f[k,z] = Lit[g,NIL,k]
    where g[x,y] = Lit[h,y,z]
      where h[p,q] = Cons[Cons[x,p],q]

The notable fact here is that the above definition makes use of the function Lit (the name standing for list iterator), known as foldr in Haskell or Standard ML: a function that traverses a list while doing some computation on its elements, thus accumulating a certain value. Using ‘folds’ and other higher-order functions is characteristic of modern functional programming, where such functions are exploited to the end of replacing explicit recursion with pure application.

Links of Relevance:

D.W. Barron, J.N. Buxton, D.F. Hartley, E. Nixon, C. Strachey. The main features of CPL. The Computer Journal, Vol.6, No.2, pp.134-143 (1963)

C. Strachey. Fundamental concepts in programming languages, 1967

Catalogue of the papers and correspondence of Christopher Strachey, the main designer of CPL

O. Danvy, M. Spivey. On Barron and Strachey's Cartesian product function, 2007

Higher-Order and Symbolic Computation, Vol.13, #1/2 (April 2000). Special issue in memory of Christopher Strachey

boykobbatgmaildotcom