Skip to main content

A New Formalization of Subtyping to Match Subclasses to Subtypes

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 8475))

Abstract

Most object-oriented languages do not support explicit recursive types, which are useful to define binary methods and some kinds of factory methods, because explicit recursive types lead to a mismatch between subclassing and subtyping. This mismatch means that an expression of a subclass may not always be usable in a context where an expression of a superclass is expected, which is not intuitive in an object-oriented setting.

In this paper, we present a new subtyping formalization, which allows subclassing to match subtyping even in the presence of recursive types in an object-oriented language. The formalization comes from a new perspective on object types and subtyping, which clearly distinguishes object types and some-object types and defines a new subtype relation on some-object types. We formally prove that the new subtype relation can successfully replace the traditional one and that subclassing always matches subtyping even in the presence of recursive types in a language. We believe that our formalization makes it easier to understand objects than the traditional formalization because of a simple encoding of objects in a typed lambda calculus.

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

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Abadi, M., Cardelli, L.: On subtyping and matching. ACM Trans. Program. Lang. Syst. 18(4), 401–423 (1996)

    Article  Google Scholar 

  2. Abadi, M., Cardelli, L.: A Theory of Objects. Springer-Verlag New York, Inc., Secaucus (1996)

    Google Scholar 

  3. Bruce, K., Cardelli, L., Castagna, G., Leavens, G.T., Pierce, B.: On binary methods. Theory and Practice of Object Systems 1, 221–242 (1995)

    Google Scholar 

  4. Oulmakhzoune, S., Foster, J.N.: LOOJ: Weaving LOOM into Java. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 390–414. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  5. Bruce, K., Odersky, M., Wadler, P.: A statically safe alternative to virtual types. In: Jul, E. (ed.) ECOOP 1998. LNCS, vol. 1445, Springer, Heidelberg (1998)

    Google Scholar 

  6. Bruce, K., Petersen, L., Fiech, A.: Subtyping is not a good “match” for object-oriented languages. In: Akşit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, Springer, Heidelberg (1997)

    Google Scholar 

  7. Bruce, K., Schuett, A., van Gent, R., Fiech, A.: PolyTOIL: A type-safe polymorphic object-oriented language. ACM TOPLAS 25, 225–290 (2003)

    Article  Google Scholar 

  8. Cardelli, L.: A semantics of multiple inheritance. In: Kahn, G., MacQueen, D.B., Plotkin, G. (eds.) Semantics of Data Types. LNCS, vol. 173, pp. 51–67. Springer, Heidelberg (1984)

    Chapter  Google Scholar 

  9. Cardelli, L.: Amber. In: Cousineau, G., Curien, P.-L., Robinet, B. (eds.) LITP 1985. LNCS, vol. 242, pp. 21–47. Springer, Heidelberg (1986)

    Chapter  Google Scholar 

  10. Cook, W.: A proposal for making Eiffel type-safe. The Computer Journal, 57–70 (1989)

    Google Scholar 

  11. Cook, W.R., Hill, W., Canning, P.S.: Inheritance is not subtyping. In: Proceedings of the 17th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 125–135. ACM, New York (1990)

    Chapter  Google Scholar 

  12. Eifrig, J., Smith, S., Trifonov, V., Zwarico, A.: An interpretation of typed oop in a language with state. LISP and Symbolic Computation 8, 357–397 (1995)

    Article  Google Scholar 

  13. Fisher, K., Mitchell, J.C.: The development of type systems for object-oriented languages. Technical report, Stanford, CA, USA (1996)

    Google Scholar 

  14. Gosling, J., Joy, B., Steele, G., Bracha, G., Buckley, A.: The JavaTM Language Specification, Java SE 7 Edition. Oracle America, Inc. (February 2012)

    Google Scholar 

  15. Hofmann, M., Pierce, B.: A unifying type-theoretic framework for objects. Journal of Functional Programming 5(04), 593–635 (1995)

    Article  MathSciNet  Google Scholar 

  16. Kamin, S.: Inheritance in Smalltalk-80: a denotational definition. In: Proceedings of the 15th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (1988)

    Google Scholar 

  17. Kamin, S.N., Reddy, U.S.: Two semantic models of object-oriented languages. In: Gunter, C.A., Mitchell, J.C. (eds.) Theoretical Aspects of Object-Oriented Programming, pp. 463–495. MIT Press (1994)

    Google Scholar 

  18. LaLonde, W., Pugh, J.: Subclassing ≠ subtyping ≠ is-a. J. Object Oriented Program. 3(5), 57–62 (1991)

    Google Scholar 

  19. Lindholm, T., Yellin, F., Bracha, G., Buckley, A.: The JavaTM Virtual Machine Specification, Java SE 7 Edition. Oracle America, Inc. (February 2012)

    Google Scholar 

  20. Mitchell, J.C.: Toward a typed foundation for method specialization and inheritance. In: POPL 1990 (1990)

    Google Scholar 

  21. Na, H., Ryu, S.: ThisJava: An extension of Java with exact types. In: Shan, C.-c. (ed.) APLAS 2013. LNCS, vol. 8301, pp. 233–240. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  22. Hyunik, N., Sukyoung, R., Kwangmoo, C.: Exact type parameterization and ThisType support. In: TLDI 2012 (2012)

    Google Scholar 

  23. Odersky, M., Spoon, L., Venners, B.: Programming in Scala. Artima Inc. (2008)

    Google Scholar 

  24. Pierce, B.C.: Types and Programming Languages. The MIT Press (2002)

    Google Scholar 

  25. Pierce, B.C., Turner, D.N.: Simple type-theoretic foundations for object-oriented programming. Journal of Functional Programming 4(02), 207–247 (1994)

    Article  MATH  Google Scholar 

  26. Reddy, U.: Objects as closures: abstract semantics of object-oriented languages. In: Proceedings of the 1988 ACM Conference on LISP and Functional Programming (1988)

    Google Scholar 

  27. Saito, C., Igarashi, A.: Matching ThisType to subtyping. In: Proceedings of the 2009 ACM Symposium on Applied Computing, SAC 2009, pp. 1851–1858. ACM, New York (2009)

    Google Scholar 

  28. Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115, 38–94 (1992)

    Article  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer International Publishing Switzerland

About this paper

Cite this paper

Na, H., Ryu, S. (2014). A New Formalization of Subtyping to Match Subclasses to Subtypes. In: Codish, M., Sumii, E. (eds) Functional and Logic Programming. FLOPS 2014. Lecture Notes in Computer Science, vol 8475. Springer, Cham. https://doi.org/10.1007/978-3-319-07151-0_15

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-07151-0_15

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-07150-3

  • Online ISBN: 978-3-319-07151-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics