Type-Safe Compilation of Covariant Specialization: A Practical Case

Despite its lack of type safety, some typed object-oriented languages use covariant specialization for methods. In this work, we show how one may modify the semantics of languages that use covariant specialization in order to improve their type safety. We demonstrate our technique using O2, a strongly and statically typed object-oriented database programming language which uses covariant specialization. We propose a modification to the O2 compiler that adds code to correct previously ill-typed computations that arise from the use of covariant specialization. The modification we propose does not affect the semantics of those computations without type errors. Furthermore, the new semantics of the previously ill-typed computations is defined in a very ``natural'''' way and ensures the type safety (w.r.t. covariance) of the program. Since the solution consists of a conservative backward-compatible modification of the compiler, it does not require, unlike other solutions, any modification of existing O2 code. Our solution is based solely on a type-theoretic analysis and thus is general. Therefore, although this paper applies it to a particular programming language, the same ideas could easily be applied to other languages that uses covariant specialization.

[1]  John G. Hosking,et al.  Multi-Methods in a Statically-Typed Programming Language , 1991, ECOOP.

[2]  William R. Cook,et al.  Object-Oriented Programming Versus Abstract Data Types , 1990, REX Workshop.

[3]  Rakesh Agrawal,et al.  Static type checking of multi-methods , 1991, OOPSLA '91.

[4]  Myles F. Barrett,et al.  A note on covariance and contravariance unification , 1996, SIGP.

[5]  Giuseppe Castagna,et al.  A Calculus for Overloaded Functions with Subtyping , 1995, Inf. Comput..

[6]  Andrew P. Black,et al.  Object structure in the Emerald system , 1986, OOPSLA 1986.

[7]  Eric Simon,et al.  Type-safe relaxing of schema consistency rules for flexible modelling in OODBMS , 1996, The VLDB Journal.

[8]  Giuseppe Castagna,et al.  A calculus for overloaded functions with subtyping , 1992, LFP '92.

[9]  Luca Cardelli,et al.  A Semantics of Multiple Inheritance , 1984, Information and Computation.

[10]  Gary T. Leavens,et al.  Typechecking and Modules for Multimethods , 1995, ACM Trans. Program. Lang. Syst..

[11]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[12]  Andrew P. Black,et al.  Object structure in the Emerald system , 1986, OOPLSA '86.

[13]  Daniel H. H. Ingalls A Simple Technique for Handling Multiple Polymorphism , 1986, OOPSLA.

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

[15]  Giuseppe Castagna,et al.  Object-Oriented Programming A Unified Foundation , 1997, Progress in Theoretical Computer Science.

[16]  Daniel H. H. Ingalls A simple technique for handling multiple polymorphism , 1986, OOPSLA 1986.

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

[18]  François Bancilhon,et al.  The O2 object-oriented database system , 1992, SIGMOD '92.

[19]  Giuseppe Castagna,et al.  A Meta-Language for Typed Object-Oriented Languages , 1995, Theor. Comput. Sci..

[20]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

[21]  Bruce G. Lindsay,et al.  Static type checking of multi-methods , 1991, OOPSLA '91.

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

[23]  Giuseppe Castagna,et al.  Covariance and contravariance: conflict without a cause , 1995, TOPL.

[24]  J. Davenport Editor , 1960 .

[25]  Giuseppe Castagna A Meta-Language for Typed Object-Oriented Languages , 1995, Theor. Comput. Sci..

[26]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .

[27]  Luca Cardelli,et al.  On Binary Methods , 1995, Theory Pract. Object Syst..