Type systems for object-oriented programming languages

John C. Mitchell, Kathleen Fisher · 1996

Object-oriented programming languages (OOPL's) provide important support for today's large-scale software projects. Unfortunately, typed OOPL's, such as Simula and C++, have suffered from overly restrictive type systems. Among other things, the rigidity of these systems force programmers to use type-casts to achieve flexibility, a notorious source of hard-to-find bugs. These restrictive type systems also mean that programming idioms common to untyped OOPL's, such as Smalltalk, are not typeable. One source of this inflexibility is the conflation of subtyping and inheritance. Briefly, inheritance is an implementation technique in which new object definitions are given as incremental modifications to existing ones. Subtyping concerns substitutivity: when can one object safely replace another? By tying subtyping to inheritance, existing OOPL's reduce the number of legal substitutions in a system and hence their degree of polymorphism. Attempts to fix this rigidity have resulted in unsound type systems, most notably Eiffel's. This thesis develops a sound type system for a formal object-oriented language that addresses this lack. It gains flexibility by separating subtyping and inheritance. It also supports method specialization, which means that the types of methods may be refined in certain ways during inheritance. The lack of such a mechanism is one of the key sources of type-casts in languages like C++ and Object Pascal. Abstraction primitives in this formal language support a class construct similar to the one found in C++, Eiffel, and Java. This study explains the link between inheritance and subtyping: object types that include implementation information are a form of abstract type, and the only way to produce a subtype of an abstract type is via extension, (i.e., by inheritance). The study also suggests that object primitives and encapsulation are orthogonal language features that together produce an object-oriented language. Hence, adding object primitives to a language that supports encapsulation (such as ML) should be sufficient to create an object-oriented language. Formally, the language is presented as an object calculus and a type system with row variables, variance annotations, method-absence annotations, and abstract types. The thesis proves type soundness with respect to an operational semantics via a subject reduction theorem.

Read the paper · More papers on PaperTik