Integrating Nominal and Structural Subtyping

  • Donna Malayeri
  • Jonathan Aldrich
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5142)

Abstract

Nominal and structural subtyping each have their own strengths and weaknesses. Nominal subtyping allows programmers to explicitly express design intent, and, when types are associated with run time tags, enables run-time type tests and external method dispatch. On the other hand, structural subtyping is flexible and compositional, allowing unanticipated reuse. To date, nearly all object-oriented languages fully support one subtyping paradigm or the other.

In this paper, we describe a core calculus for a language that integrates the key aspects of nominal and structural subtyping in a unified framework. We have also merged the flexibility of structural subtyping with statically typechecked external methods, a novel combination. We prove type safety for this language and illustrate its practical utility through examples that are not easily expressed in other languages. Our work provides a clean foundation for the design of future languages that enjoy the benefits of both nominal and structural subtyping.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Bono, V., Damiani, F., Giachino, E.: Separating Type, Behavior, and State to Achieve Very Fine-grained Reuse. In: Electronic proceedings of FTfJP (2007), http://www.cs.ru.nl/ftfjp/
  2. 2.
    Bracha, G., Cook, W.: Mixin-based inheritance. In: ECOOP 1990(1990)Google Scholar
  3. 3.
    Bracha, G., Griswold, D.: Strongtalk: typechecking Smalltalk in a production environment. In: OOPSLA 1993, pp. 215–230 (1993)Google Scholar
  4. 4.
    Bruce, K.B., Schuett, A., Gent, R.V., Fiech, A.: PolyTOIL: A type-safe polymorphic object-oriented language. ACM Trans. Program. Lang. Syst. 25(2), 225–290 (2003)CrossRefGoogle Scholar
  5. 5.
    Castagna, G., Ghelli, G., Longo, G.: A calculus for overloaded functions with subtyping. Inf. Comput. 117(1), 115–135 (1995)MATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Chambers, C.: Object-oriented multi-methods in Cecil. In: Lehrmann Madsen, O. (ed.) ECOOP 1992. LNCS, vol. 615. Springer, Heidelberg (1992)CrossRefGoogle Scholar
  7. 7.
    Chambers, C.: Cecil Group. The Cecil language: specification and rationale, version 3.2 (February 2004), http://www.cs.washington.edu/research/projects/cecil/
  8. 8.
    Clifton, C., Millstein, T., Leavens, G.T., Chambers, C.: MultiJava: Design rationale, compiler implementation, and applications. ACM Trans. Program. Lang. Syst. 28(3), 517–575 (2006)CrossRefGoogle Scholar
  9. 9.
    Davies, R., Pfenning, F.: Intersection types and computational effects. In: ICFP 2000, pp. 198–208 (2000)Google Scholar
  10. 10.
    Fisher, K., Reppy, J.: The design of a class mechanism for Moby. In: PLDI 1999, pp. 37–49 (1999)Google Scholar
  11. 11.
    Fisher, K., Reppy, J.: Inheritance-based subtyping. Inf. Comput. 177(1), 28–55 (2002)MATHCrossRefMathSciNetGoogle Scholar
  12. 12.
  13. 13.
    Gregor, D., Järvi, J., Siek, J., Stroustrup, B., Reis, G.D., Lumsdaine, A.: Concepts: Linguistic support for generic programming in C++. In: Proceedings of OOPSLA 2006, October 2006, pp. 291–310. ACM Press, New York (2006)CrossRefGoogle Scholar
  14. 14.
    Leroy, X., Doligez, D., Garrigue, J., Rémy, D., Vouillon, J.: The Objective Caml system, release 3.09 (2004), http://caml.inria.fr/pub/docs/manual-ocaml/index.html
  15. 15.
    Madsen, O.L., Moller-Pedersen, B.: Virtual classes: a powerful mechanism in object-oriented programming. In: OOPSLA 1989, pp. 397–406 (1989)Google Scholar
  16. 16.
    Malayeri, D., Aldrich, J.: Combining structural subtyping and external dispatch. In: FOOL/WOOD 2007 (January 2007), http://foolwood07.cs.uchicago.edu/program.html
  17. 17.
    Malayeri, D., Aldrich, J.: Integrating Nominal and Structural Subtyping. Technical Report CMU-CS-08-120, School of Computer Science, Carnegie Mellon University (May 2008)Google Scholar
  18. 18.
    Sun Microsystems. Java collections API design FAQ (2003), http://java.sun.com/j2se/1.4.2/docs/guide/collections/designfaq.html
  19. 19.
    Millstein, T.D., Chambers, C.: Modular statically typed multimethods. Inf. Comput. 175(1), 76–118 (2002)MATHCrossRefMathSciNetGoogle Scholar
  20. 20.
    Nelson, G. (ed.): Systems programming with Modula-3. Prentice-Hall, Inc., Upper Saddle River (1991)Google Scholar
  21. 21.
    Nystrom, N., Chong, S., Myers, A.C.: Scalable extensibility via nested inheritance. In: OOPSLA 2004, pp. 99–115 (2004)Google Scholar
  22. 22.
    Odersky, M.: The Scala language specification (2007), http://www.scala-lang.org/docu/files/ScalaReference.pdf
  23. 23.
    Ostermann, K.: Nominal and Structural Subtyping in Component-Based Programming. Journal of Object Technology 7(1) (2008)Google Scholar
  24. 24.
    Reppy, J., Turon, A.: Metaprogramming with traits. In: Ernst, E. (ed.) ECOOP 2007. LNCS, vol. 4609. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  25. 25.
    Schärli, N., Ducasse, S., Nierstrasz, O., Black, A.: Traits: Composable units of behavior. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743. Springer, Heidelberg (2003)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • Donna Malayeri
    • 1
  • Jonathan Aldrich
    • 1
  1. 1.Carnegie Mellon UniversityPittsburghUSA

Personalised recommendations