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 use covariant specialization.
Unable to display preview. Download preview PDF.
- [ABDS96]E. Amiel, M.-J. Bellosta, E. Dujardin, and E. Simon. Type-safe relaxing of schema consistency rules for flexible modelling in OODBMS. Very Large Databases Journal, 5(2):108–119, April 1996.Google Scholar
- [BCC+96]K. Bruce, L. Cardelli, G. Castagna, The Hopkins Object Group, G. Leavens, and B. Pierce. On binary methods. Theory and Practice of Object Systems, 1(3), 1996.Google Scholar
- [BDK92]F. Bancilhon, C. Delobel, and P. Kanellakis, editors. Implementing an Object-Oriented Database System: The Story of O 2. Morgan Kaufmann, 1992.Google Scholar
- [BHJL86]A. Black, N. Hutchinson, E. Jul, and H. Levy. Object structure in the Emerald system. In Norman Meyrowitz, editor, OOPSLA '86 Conference Proceedings, volume 21(11) of SIGPLAN Notices, pages 347–349, Nov. 1986.Google Scholar
- [Cas96]G. Castagna. Object-Oriented Programming: A Unified Foundation. Progress in Theoretical Computer Science. Birkäuser, Boston, 1996.Google Scholar
- [CGL95]G. Castagna, G. Ghelli, and G. Longo. A calculus for overloaded functions with subtyping. Information and Computation, 117(1):115–135, 1995, A preliminary version was presented at the 1992 ACM Conference on LISP and Functional Programming, San Francisco, June 1992.MathSciNetCrossRefMATHGoogle Scholar
- [Coo91]W. Cook. Object-oriented programming versus abstract data types. In J. W. de Bakker, W. P. de Roever, and G. Rozenberg, editors, Foundations of Object-Oriented Languages, REX School/Workshop, volume 489 of LNCS, pages 151–178. Springer-Verlag, 1991.Google Scholar
- [DG87]L.G. DeMichiel and R.P. Gabriel. Common Lisp Object System overview. In Bézivin, Hullot, Cointe, and Lieberman, editors, ECOOP '87 Conference Proceedings, volume 276 of LNCS, pages 151–170. Springer-Verlag, 1987.Google Scholar
- [Ing86]D. H. H. Ingalls. A simple technique for handling multiple polymorphism. In Norman Meyrowitz, editor, OOPSLA '86 Conference Proceedings, volume 21(11) of SIGPLAN Notices, pages 347–349, Nov. 1986.Google Scholar
- [Mey91]Bertrand Meyer. Eiffel: The Language. Prentice-Hall, 1991.Google Scholar
- [Mey96]Bertrand Meyer. Object-Oriented Software Construction. Prentice-Hall, 2nd edition, to appear 1996.Google Scholar
- [MHH91]W. B. Mugridge, J. G. Hosking, and J. Hamer. Multi-methods in a statically-typed programming language. In P. America, editor, ECOOP '91 Conference Proceedings, volume 512 of LNCS, pages 307–324. Springer-Verlag, 1991.Google Scholar