Lightweight Family Polymorphism

  • Atsushi Igarashi
  • Chieri Saito
  • Mirko Viroli
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3780)


Family polymorphism has been proposed for object-oriented languages as a solution to supporting reusable yet type-safe mutually recursive classes. A key idea of family polymorphism is the notion of families, which are used to group mutually recursive classes. In the original proposal, due to the design decision that families are represented by objects, dependent types had to be introduced, resulting in a rather complex type system. In this paper, we propose a simpler solution of lightweight family polymorphism, based on the idea that families are represented by classes rather than objects. This change makes the type system significantly simpler without losing much expressibility of the language. Moreover, “family-polymorphic” methods now take a form of parametric methods; thus it is easy to apply the Java-style type inference. To rigorously show that our approach is safe, we formalize the set of language features on top of Featherweight Java and prove the type system is sound. An algorithm of type inference for family-polymorphic method invocations is also formalized and proved to be correct.


Type System Operational Semantic Dependent Type Member Class Type Inference 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aspinall, D., Hofmann, M.: Dependent types. In: Pierce, B.C. (ed.) Advanced Topics in Types and Programming Languages, ch. 2, pp. 45–86. MIT Press, Cambridge (2005)Google Scholar
  2. 2.
    Bracha, G., Odersky, M., Stoutamire, D., Wadler, P.: Making the future safe for the past: Adding genericity to the Java programming language. In: Proceedings of OOPSLA 1998, Vancouver, BC, October 1998, pp. 183–200 (1998)Google Scholar
  3. 3.
    Bruce, K.B.: Some challenging typing issues in object-oriented languages. In: Proceedings of Workshop on Object-Oriented Development (WOOD 2003). Electronic Notes in Theoretical Computer Science, vol. 82 (2003)Google Scholar
  4. 4.
    Bruce, K.B., Cardelli, L., Castagna, G., The Hopkins Objects Group, Leavens, G.T., Pierce, B.: On binary method. Theory and Practice of Object Systems 1(3), 221–242 (1996)Google Scholar
  5. 5.
    Bruce, K.B., Foster, J.N.: LOOJ: Weaving LOOM into Java. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 390–414. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  6. 6.
    Bruce, K.B., Odersky, M., Wadler, P.: A statically safe alternative to virtual types. In: Jul, E. (ed.) ECOOP 1998. LNCS, vol. 1445, pp. 523–549. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  7. 7.
    Bruce, K.B., Petersen, L., Fiech, A.: Subtyping is not a good “match” for object-oriented languages. In: Aksit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 104–127. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  8. 8.
    Bruce, K.B., Vanderwaart, J.C.: Semantics-driven language design: Statically type-safe virtual types in object-oriented languages. In: Proceedings of 15th Conference on the Mathematical Foundations of Programming Semantics (MFPS XV), New Orleans, LA, April 1999. ENTCS, vol. 20. Elsevier, Amsterdam (1999)Google Scholar
  9. 9.
    Canning, P., Cook, W., Hill, W., Olthoff, W., Mitchell, J.C.: F-bounded polymorphism for object-oriented programming. In: Proceedings of FPCA 1989, London, England, September 1989, pp. 273–280. ACM Press, New York (1989)CrossRefGoogle Scholar
  10. 10.
    Ernst, E.: gbeta – A Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. PhD thesis, Department of Computer Science, University of Aarhus, Aarhus, Denmark (June 1999)Google Scholar
  11. 11.
    Ernst, E.: Family polymorphism. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 303–326. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  12. 12.
    Ernst, E.: Higher-order hierarchies. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 303–328. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  13. 13.
    Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: Proceedings of POPL 1998, San Diego, CA, January 1998, pp. 171–183 (1998)Google Scholar
  14. 14.
    Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems 23(3), 396–450 (2001)CrossRefGoogle Scholar
  15. 15.
    Jolly, P., Drossopoulou, S., Anderson, C., Ostermann, K.: Simple dependent types: Concord. In: Proceedings of 6th ECOOP Workshop on Formal Techniques for Java-like Programs (FTfJP 2004) (June 2004)Google Scholar
  16. 16.
    Madsen, O.L., Møller-Pedersen, B.: Virtual classes: A powerful mechanism in object-oriented programming. In: Proceedings of OOPSLA 1989, October 1989, pp. 397–406 (1989)Google Scholar
  17. 17.
    Nystrom, N., Chong, S., Myers, A.C.: Scalable extensibility via nested inheritance. In: Proceedings of OOPSLA 2004 (October 2004)Google Scholar
  18. 18.
    Odersky, M.: Inferred type instantiation for GJ (January 2002), Available at
  19. 19.
    Odersky, M., Cremet, V., Röckl, C., Zenger, M.: A nominal theory of objects with dependent types. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 201–224. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  20. 20.
    Thorup, K.K., Torgersen, M.: Unifying genericity: Combining the benefits of virtual types and parameterized classes. In: Guerraoui, R. (ed.) ECOOP 1999. LNCS, vol. 1628, pp. 186–204. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  21. 21.
    Torgersen, M.: The expression problem revisited: Four new solutions using generics. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  22. 22.
    Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115(1), 38–94 (1994)zbMATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Atsushi Igarashi
    • 1
  • Chieri Saito
    • 1
  • Mirko Viroli
    • 2
  1. 1.Kyoto UniversityJapan
  2. 2.Alma Mater Studiorum – Università di Bologna a CesenaItaly

Personalised recommendations