Lightweight Family Polymorphism
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.
KeywordsType System Operational Semantic Dependent Type Member Class Type Inference
Unable to display preview. Download preview PDF.
- 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.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.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.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
- 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
- 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
- 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
- 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.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.Nystrom, N., Chong, S., Myers, A.C.: Scalable extensibility via nested inheritance. In: Proceedings of OOPSLA 2004 (October 2004)Google Scholar
- 18.Odersky, M.: Inferred type instantiation for GJ (January 2002), Available at http://lampwww.epfl.ch/~odersky/papers/localti02.html