CSE 230: Principles of Programming Languages
Notes on Chapter 4 of Stansifer (data types)

4.0 We can motivate the need for programming languages to provide constructs to define data types in much the same that we motivated the need for constructs to define control: without them, the code hides the intent of the programmer. Just as the unrestricted use of goto's can produce spaghetti code in which it is very hard to understand the flow of control, so the unrestricted use of pointers can produce spaghetti storage in which it is very hard to understand the structure of data. Just as programming languages slowly evolved better and better constructs for control flow, so they have also evolved better and better constructs for structuring data. The main concept is that of a type, which is a name for a collection of data items (i.e., r-values) having similar structure; the types of a language divide its data items into distinct (but usually not disjoint) classes.

If a language has a good type system, then programs will be easier to read, in that it will be clearer what is going on; moreover, the compiler will be able to detect many errors, so that programs will also be easier to write. A strongly typed language requires type declarations for all r-values, whereas an untyped language requires no type declarations. Older languages tend to be less strongly typed than newer languages.

4.3 The punch line on page 119, about motivation for abstract types is especially important, and could be taken to refer to much of the other material in this section.

4.5.1 The classification of the different kinds of polymorphism is due to Christopher Strachey of Oxford University, in lectures notes from 1967. This is the same Strachey who introduced the language CPL which was implemented as BCPL and which inspired C (the "C" is for Christopher); he also introduced the very useful notions of "l-value" and "r-value" in these same lecture notes; and he is the co-founder with Dana Scott of denotational semantics.

4.5.2 Ada generics were designed by Bernd Krieg-Bruckner, who is one of the leading European researchers on algebraic specification, now at the University of Bremen, based on OBJ parameterized modules, though only part of the OBJ functionality is included in Ada; in fact, the extra power of OBJ modules avoids the difficulty with Ada described on page 126, through the use of its interface theories.

4.5.3 There is a small bug on page 127, since the type real is not in the language definition, and there is another small bug on page 129, since the identifier l should be associated with the type `a, not bool. More importantly there is a bug in Theorem 3 on page 130, since the type variable tau is "floating" in the way the result is stated; the easiest way to fix it is to insert "some" before the first instance of tau.

To CSE 230 homepage
To CSE 230 notes page
Maintained by Joseph Goguen
© 2000, 2001, 2002 Joseph Goguen
Last modified: Wed Feb 13 21:48:06 PST 2002