Skip to main content

Type-safe compilation of covariant specialization: A practical case

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1098))

Abstract

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.

The work of John Boyland was supported in part by Advanced Research Projects Agency grant MDA972-92-J-1028, and by NSF Infrastructure grant CDA-9401156. The content of this paper does not necessarily reflect the position or the policy of the U. S. Government, and no official endorsement should be inferred.

This is a preview of subscription content, log in via an institution.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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 

  2. R. Agrawal, L. DeMichiel, and B. Lindsay. Static type checking of multi-methods. ACM SIGPLAN Notices, 26(11):113–128, 1991. Proceedings of OOPSLA'91.

    Article  Google Scholar 

  3. 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 

  4. F. Bancilhon, C. Delobel, and P. Kanellakis, editors. Implementing an Object-Oriented Database System: The Story of O 2. Morgan Kaufmann, 1992.

    Google Scholar 

  5. M. F. Barrett and M. E. Giguere. A note on covariance and contravariance unification. ACM SIGPLAN Notices, 31(1):32–35, Jan. 1996.

    Article  Google Scholar 

  6. 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 

  7. K.B. Bruce. A paradigmatic object-oriented programming language: Design, static typing and semantics. Journal of Functional Programming, 4(2):127–206, 1994.

    Article  MATH  MathSciNet  Google Scholar 

  8. L. Cardelli. A semantics of multiple inheritance. Information and Computation, 76:138–164, 1988. A previous version can be found in Semantics of Data Types, LNCS 173, 51–67, Springer-Verlag, 1984.

    Article  MATH  MathSciNet  Google Scholar 

  9. G. Castagna. Covariance and contravariance: conflict without a cause. ACM Transactions on Programming Languages and Systems, 17(3):431–447, 1995.

    Article  Google Scholar 

  10. G. Castagna. A meta-language for typed object-oriented languages. Theoretical Computer Science, 151(2):297–352, Nov. 1995.

    Article  MATH  MathSciNet  Google Scholar 

  11. G. Castagna. Object-Oriented Programming: A Unified Foundation. Progress in Theoretical Computer Science. Birkäuser, Boston, 1996.

    Google Scholar 

  12. 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.

    Article  MathSciNet  MATH  Google Scholar 

  13. C. Chambers and G. Leavens. Typechecking and modules for multi-methods. ACM Transactions on Programming Languages and Systems, 17(6):805–843, Nov. 1995.

    Article  Google Scholar 

  14. 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 

  15. 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 

  16. A. Goldberg and D. Robson. Smalltalk-80: The Language and Its Implementation. Addison-Wesley, Reading, Mass., 1983.

    MATH  Google Scholar 

  17. 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 

  18. Bertrand Meyer. Eiffel: The Language. Prentice-Hall, 1991.

    Google Scholar 

  19. Bertrand Meyer. Object-Oriented Software Construction. Prentice-Hall, 2nd edition, to appear 1996.

    Google Scholar 

  20. 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 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Pierre Cointe

Rights and permissions

Reprints and permissions

Copyright information

© 1996 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Boyland, J., Castagna, G. (1996). Type-safe compilation of covariant specialization: A practical case. In: Cointe, P. (eds) ECOOP ’96 — Object-Oriented Programming. ECOOP 1996. Lecture Notes in Computer Science, vol 1098. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0053054

Download citation

  • DOI: https://doi.org/10.1007/BFb0053054

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-61439-5

  • Online ISBN: 978-3-540-68570-8

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics