CLU is a programming language created at MIT by Barbara Liskov and her students between 1974 and 1975. It was notable for its use of constructors for abstract data types that included the code that operated on them, a key step in the direction of object-oriented programming (OOP). However many of the other features of OOP are missing or incomplete, notably inheritance, and the language is also hindered by a sometimes frustrating syntax. CLU and Alphard both seem to get as close as possible to being a full OO language without actually being one.
complex_number = cluster is add, subtract, multiply, ...
rep = record [real_part: real, imag_part: real ]
add = proc ... end add;
subtract = proc ... end subtract;
multiply = proc ... end multiply;
While clusters offered a then-advanced system for structuring programs, CLU did not offer any sort of structure for the clusters themselves. Cluster names are global, and no namespace mechanism was provided to group clusters or allow them to be created "locally" inside other clusters. This problem is not unique to CLU, but it is surprising that so many languages have lacked this feature — given the centralness in ALGOL of giving scope to variables, it seems that giving scope to cluster/object names would be an obvious extension.
CLU does not perform implicit type conversions. In a cluster, the explicit type conversions 'up' and 'down' change between the abstract type and the representation. There is a universal type 'any', and a procedure force to check that an object is a certain type. Objects may be mutable or immutable, the latter being "base types" such as integers.
complex_numbers would be identical to that for an array of
integers. Iterators are now a common feature of most modern languages. (See Generator)
CLU also includes exception handling, based on various attempts in other languages; exceptions are raised using
signal and handled with
except. Oddly, given the focus on type design, CLU does not offer enumerated types, nor any obvious way to create them.
A final distinctive feature in CLU is multiple assignment, where more than one variable can appear on the left hand side of an assignment operator. For instance, writing
x,y = y,x would exchange values of
y. In the same way, functions could return several values, like
x,y,z = f(t).
All objects in a CLU program live in the heap, and memory management is automatic.