Publications » Class » PolymorphismJfp38

Lightweight Family Polymorphism

Chieri Saito, Atsushi Igarashi, Mirko Viroli
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 article, we propose a simpler solution of lightweight family polymorphism, based on the idea that families are represented by classes rather than by objects. This change makes the type system significantly simpler without losing much expressive power of the language. Moreover, "family-polymorphic" methods now take a form of parametric methods; thus, it is easy to apply method type argument inference as in Java 5.0. To rigorously show that our approach is safe, we formalize the set of language features on top of Featherweight Java and prove that the type system is sound. An algorithm for type inference for family-polymorphic method invocations is also formalized and proved to be correct. Finally, a formal translation by erasure to Featherweight Java is presented; it is proved to preserve typing and execution results, showing that our new language features can be implemented in Java by simply extending the compiler.
Keywords: inheritance, family polymorphism, Featherweight Java
Journal of Functional Programming 18(3), pages 285-331, May 2008, Cambridge University Press
A preliminary summary appeared in the proceedings of the third Asian Symposium on Programming Languages and Systems (APLAS2005), volume 3780 of Lecture Notes in Computer Science, Tsukuba, Japan, November 2005, Springer-Verlag, pp. 161?177.
@article{PolymorphismJfp18,
	issn = {0956-7968},
	volume = 18,
	title = {Lightweight Family Polymorphism},
	publisher = {Cambridge University Press},
	url = {http://journals.cambridge.org/action/displayAbstract?fromPage=online&aid=1827916},
	number = 3,
	month = may,
	doi = {10.1017/S0956796807006405},
	keywords = {inheritance, family polymorphism, Featherweight Java},
	note = {A preliminary summary appeared in the proceedings of the third Asian Symposium on Programming Languages and Systems (APLAS2005), volume 3780 of Lecture  Notes in Computer Science, Tsukuba, Japan, November 2005, Springer-Verlag, pp. 161-177},
	issn-online = {1469-7653},
	year = 2008,
	pages = {285-331},
	journal = {Journal of Functional Programming},
	author = {Saito, Chieri and Igarashi, Atsushi and Viroli, Mirko}}