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
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Abadi, M., Cardelli, L.: On subtyping and matching. ACM Trans. Program. Lang. Syst. 18(4), 401–423 (1996)
Abadi, M., Cardelli, L.: A Theory of Objects. Springer-Verlag New York, Inc., Secaucus (1996)
Bruce, K., Cardelli, L., Castagna, G., Leavens, G.T., Pierce, B.: On binary methods. Theory and Practice of Object Systems 1, 221–242 (1995)
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)
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)
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)
Bruce, K., Schuett, A., van Gent, R., Fiech, A.: PolyTOIL: A type-safe polymorphic object-oriented language. ACM TOPLAS 25, 225–290 (2003)
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)
Cardelli, L.: Amber. In: Cousineau, G., Curien, P.-L., Robinet, B. (eds.) LITP 1985. LNCS, vol. 242, pp. 21–47. Springer, Heidelberg (1986)
Cook, W.: A proposal for making Eiffel type-safe. The Computer Journal, 57–70 (1989)
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)
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)
Fisher, K., Mitchell, J.C.: The development of type systems for object-oriented languages. Technical report, Stanford, CA, USA (1996)
Gosling, J., Joy, B., Steele, G., Bracha, G., Buckley, A.: The JavaTM Language Specification, Java SE 7 Edition. Oracle America, Inc. (February 2012)
Hofmann, M., Pierce, B.: A unifying type-theoretic framework for objects. Journal of Functional Programming 5(04), 593–635 (1995)
Kamin, S.: Inheritance in Smalltalk-80: a denotational definition. In: Proceedings of the 15th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (1988)
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)
LaLonde, W., Pugh, J.: Subclassing ≠ subtyping ≠ is-a. J. Object Oriented Program. 3(5), 57–62 (1991)
Lindholm, T., Yellin, F., Bracha, G., Buckley, A.: The JavaTM Virtual Machine Specification, Java SE 7 Edition. Oracle America, Inc. (February 2012)
Mitchell, J.C.: Toward a typed foundation for method specialization and inheritance. In: POPL 1990 (1990)
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)
Hyunik, N., Sukyoung, R., Kwangmoo, C.: Exact type parameterization and ThisType support. In: TLDI 2012 (2012)
Odersky, M., Spoon, L., Venners, B.: Programming in Scala. Artima Inc. (2008)
Pierce, B.C.: Types and Programming Languages. The MIT Press (2002)
Pierce, B.C., Turner, D.N.: Simple type-theoretic foundations for object-oriented programming. Journal of Functional Programming 4(02), 207–247 (1994)
Reddy, U.: Objects as closures: abstract semantics of object-oriented languages. In: Proceedings of the 1988 ACM Conference on LISP and Functional Programming (1988)
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)
Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115, 38–94 (1992)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)