Primitive Subtyping ^ Implicit Polymorphism J = Object-orientation Extended Abstract

1 Overview We present a new predicative and decidable type system called ML that adds primitive subtyp-ing to the ML type system 17]. Our goal is to devise a type discipline for a strongly typed, higher-order object-oriented language, building on well-understood concepts from type systems for functional languages, rather than on special calculi 1] or resorting to \ad-hoc" polymor-phism 19, 23], second-order systems 6, 21], or recursive types 4]. Instead, our system is based on the following ideas. We insist on a separation of interface and implementation. Interfaces de-ne types and method signatures, where subtyp-ing provides for a hierarchical, user-extensible modelling. Implementation modules may deene data types (in the form of tagged records), which form the leaves of the type hierarchy, as well as method implementations for speciic argument types. We do not model the inheritance of implementations (which we believe to be a purely syntactic notion) in the type system. We think of methods as sets of functions, similar in spirit to languages like CLOS 7] and Cecil 5], that dispatch on the run-time types of all their arguments. We enrich the original Hindley-Milner type system 12, 17] with polymorphic constrained types of the form 8#: : where # is a set of variables, is a constraint, and is a (quantiier-free) monotype. Before we deene these notions in detail in section 2, we would like to illustrate the use of our type system at the hand of the classical example of points in the two-dimensional plane, expressed in a ctitious language with full type annotations (see gure 1). We do not study type inference in this paper, although we will come back to this issue in the conclusion. The interface Point declares a zero-ary type constructor class Point as well as a type con-structor point. Type constructors are used to form complex type expressions; we identify a zero-ary type constructor such as point with the type point ]. Type constructor classes partition the universe of type constructors into dis-joint subuniverses. In particular, we consider two types incomparable if their outermost type constructors belong to diierent classes. In OO jargon, one would call the type point an \ab-stract class", because the interface does not de-ne an implementation for points. The interface Point speciies three methods dist, move, and leq that operate on objects of type point. Method dist has type point ! real, that is, it expects an argument of …

[1]  J. Palsberg Eecient Inference of Object Types , 1995 .

[2]  John C. Mitchell,et al.  Type inference with simple subtypes , 1991, Journal of Functional Programming.

[3]  Prateek Mishra,et al.  Polymorphic Subtype Inference: Closing the Theory-Practice Gap , 1989, TAPSOFT, Vol.2.

[4]  Martín Abadi,et al.  A Theory of Primitive Objects: Second-Order Systems , 1995, Sci. Comput. Program..

[5]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[6]  I. G. BONNER CLAPPISON Editor , 1960, The Electric Power Engineering Handbook - Five Volume Set.

[7]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[8]  Ryan Stansifer,et al.  Type inference with subtypes , 1988, POPL '88.

[9]  WadlerPhilip,et al.  Report on the programming language Haskell , 1992 .

[10]  Kim B. Bruce A paradigmatic object-oriented programming language: Design, static typing and semantics , 1994, Journal of Functional Programming.

[11]  Jerzy Tiuryn Subtype inequalities , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[12]  Scott F. Smith,et al.  Sound polymorphic type inference for objects , 1995, OOPSLA.

[13]  R. Hindley The Principal Type-Scheme of an Object in Combinatory Logic , 1969 .

[14]  Martin Odersky,et al.  A second look at overloading , 1995, FPCA '95.

[15]  Gary T. Leavens,et al.  Typechecking and modules for multi-methods , 1994, OOPSLA '94.

[16]  Linda G. DeMichiel,et al.  The Common Lisp Object System: An Overview , 1987, ECOOP.

[17]  John C. Mitchell,et al.  Type Inference with Extended Pattern Matching and Subtypes , 1993, Fundamenta Informaticae.

[18]  Alexander Aiken,et al.  Type inclusion constraints and type inference , 1993, FPCA '93.

[19]  Mark P. Jones A system of constructor classes: overloading and implicit higher-order polymorphism , 1993, FPCA '93.

[20]  Benjamin C. Pierce,et al.  Simple type-theoretic foundations for object-oriented programming , 1994, Journal of Functional Programming.

[21]  Giorgio Ghelli,et al.  Coherence of Subsumption, Minimum Typing and Type-Checking in F<= , 1992, Math. Struct. Comput. Sci..

[22]  Stefan Kaes Type inference in the presence of overloading, subtyping and recursive types , 1992, LFP '92.

[23]  John C. Mitchell,et al.  Abstract types have existential type , 1988, TOPL.