Hostname: page-component-77f85d65b8-lfk5g Total loading time: 0 Render date: 2026-04-23T01:14:04.979Z Has data issue: false hasContentIssue false

Lightweight family polymorphism*

Published online by Cambridge University Press:  01 May 2008

CHIERI SAITO
Affiliation:
Kyoto University, Japan (e-mail: saito@kuis.kyoto-u.ac.jp, igarashi@kuis.kyoto-u.ac.jp)
ATSUSHI IGARASHI
Affiliation:
Kyoto University, Japan (e-mail: saito@kuis.kyoto-u.ac.jp, igarashi@kuis.kyoto-u.ac.jp)
MIRKO VIROLI
Affiliation:
Alma Mater Studiorum – Università di Bologna a Cesena, Italy (e-mail: mirko.viroli@unibo.it)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the 'Save PDF' action button.

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.

Information

Type
Articles
Copyright
Copyright © Cambridge University Press 2007
Submit a response

Discussions

No Discussions have been published for this article.