Abstract
Bruce and Foster proposed the language LOOJ, an extension of Java with the notion of MyType, which represents the type of a self reference and changes its meaning along with inheritance. MyType is useful to write extensible yet type-safe classes for objects with recursive interfaces, that is, ones with methods that take or return objects of the same type as the receiver.
Although LOOJ has also generics, MyType has been introduced as a feature rather orthogonal to generics. As a result, LOOJ cannot express an interface that refers to the same generic class recursively but with different type arguments. This is a significant limitation because such an interface naturally arises in practice, for example, in a generic collection class with method map(), which converts a collection to the same kind of collection of a different element type. Altherr and Cremet and Moors, Piessens, and Odersky gave solutions to this problem but they used a highly sophisticated combination of advanced mechanisms such as abstract type members, higher-order type constructors, and F-bounded polymorphism.
In this paper, we give another solution by introducing self type constructors, which integrate MyType and generics so that MyType can take type arguments in a generic class. Self type constructors are tailored to writing recursive interfaces more concicely than previous solutions. We demonstrate the expressive power of self type constructors by means of examples, formalize a core language with self type constructors, and prove its type safety.
- Philippe Altherr and Vincent Cremet. Adding type constructor parameterization to Java. Journal of Object Technology, 7(5):25--65, June 2008. Special Issue: Workshop on FTfJP 2007.Google Scholar
Cross Ref
- Gavin M. Bierman, Erik Meijer, and Wolfram Schulte. The essence of data access in Comega. In Proc. of ECOOP, volume 3586 of LNCS, pages 287--311, 2005. Google Scholar
Digital Library
- Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In Proc. of OOPSLA '98, pages 183--200, 1998. Google Scholar
Digital Library
- Kim B. Bruce. A paradigmatic object-oriented programming language: Design, static typing and semantics. Journal of Functional Programming, 4(2):127--206, April 1994.Google Scholar
Cross Ref
- Kim B. Bruce. Some challenging typing issues in object-oriented languages. In Proc. of WOOD'03, volume 82 of ENTCS, 2003.Google Scholar
- Kim B. Bruce, Luca Cardelli, Giuseppe Castagna, The Hopkins Objects Group, Gary T. Leavens, and Benjamin Pierce. On binary methods. Theory and Practice of Object Systems, 1(3):221--242, 1996. Google Scholar
Digital Library
- Kim B. Bruce and J. Nathan Foster. LOOJ: Weaving LOOM into Java. In Proc. of ECOOP 2004, volume 3086 of LNCS, pages 390--414, June 2004.Google Scholar
Cross Ref
- Kim B. Bruce, Martin Odersky, and Philip Wadler. A statically safe alternative to virtual types. In Proc. of ECOOP '98, volume 1445 of LNCS, pages 523--549, 1998. Google Scholar
Digital Library
- Kim B. Bruce and Joseph C. Vanderwaart. Semantics-driven language design: Statically type-safe virtual types in object-oriented languages. In Proc. of MFPS XV, volume 20 of ENTCS, 1999.Google Scholar
- Nicholas Cameron and Sophia Drossopoulou. On subtyping, wildcards, and existential types. In Proc. of FTfJP, Genoa, Italy, July 2009. Google Scholar
Digital Library
- Peter Canning, William Cook, Walter Hill, Walter Olthoff, and John C. Mitchell. F-bounded polymorphism for object-oriented programming. In Proc. of ACM Conference on Functional Programming and Computer Architecture (FPCA'89), pages 273--280, London, England, September 1989. ACM Press. Google Scholar
Digital Library
- Dave Clarke, Sophia Drossopoulou, James Noble, and Tobias Wrigstad. Tribe: A simple virtual class calculus. In Proc. of AOSD'07, pages 121--134, 2007. Google Scholar
Digital Library
- Bruno C. d. S. Oliveira. Modular visitor components: A practical solution to the expression families problem. In Proc. of ECOOP 2009, pages 269--293, July 2009. Google Scholar
Digital Library
- Burak Emir, Andrew Kennedy, Claudio Russo, and Dachuan Yu. Variance and generalized constraints for C# generics. In Proc. of ECOOP2006, volume 4067, pages 279--303, 2006. Google Scholar
Digital Library
- Erik Ernst. Family polymorphism. In Proc. of ECOOP 2001, volume 2072 of LNCS, pages 303--326, 2001. Google Scholar
Digital Library
- Erik Ernst. Higher-order hierarchies. In Proc. of ECOOP 2003, volume 2743 of LNCS, pages 303--328, 2003.Google Scholar
Cross Ref
- Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Sotfware. Addison-Wesley, 1995. Google Scholar
Digital Library
- Christian Hofer, Klaus Ostermann, Tillmann Rendel, and Adriaan Moors. Polymorphic embedding of DSLs. In Proc. of International Conference on Generative Programming and Component Engineering 2008, pages 137--148, New York, NY, USA, 2008. ACM. Google Scholar
Digital Library
- Atsushi Igarashi and Benjamin C. Pierce. Foundations for virtual types. In Rachid Guerraoui, editor, Proceedings of the 13th European Conference on Object-Oriented Programming (ECOOP'99), volume 1628 of Lecture Notes in Computer Science, pages 161--185, Lisbon, Portugal, June 1999. Springer-Verlag. Google Scholar
Digital Library
- Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. Featherweight Java: A minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems, 23(3):396--450, May 2001. A preliminary summary appeared in Proc. of OOPSLA'99. Google Scholar
Digital Library
- Atsushi Igarashi and Mirko Viroli. Variant parametric types: A flexible subtyping scheme for generics. ACM Transactions on Programming Languages and Systems, 28(5):795--847, September 2006. A preliminary version appeared under the title "On Variance-Based Subtyping for Parametric Types" in Proc. of ECOOP2002. Google Scholar
Digital Library
- Atsushi Igarashi and Mirko Viroli. Variant path types for scalable extensibility. In Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2007), pages 113--132, Montreal, QC, October 2007. Google Scholar
Digital Library
- Paul Jolly, Sophia Drossopoulou, Christopher Anderson, and Klaus Ostermann. Simple dependent types: Concord. In Proc. of FTfJP 2004, June 2004.Google Scholar
- Tetsuo Kamina and Tetsuo Tamai. Lightweight scalable components. In Proc. of 6th International Conference on Generative Programming and Component Engineering(GPCE'07), pages 145--154, October 2007. Google Scholar
Digital Library
- Erik Meijer. Confessions of a used programming language salesman. In Proc. of OOPSLA, pages 677--694, 2007. Google Scholar
Digital Library
- Bertrand Meyer. Genericity versus inheritance. In Proc. of OOPSLA, pages 391--405, 1986. Google Scholar
Digital Library
- Adriaan Moors, Frank Piessens, and Martin Odersky. Generics of a higher kind. In Proc. of OOPSLA (OOPSLA'08), pages 423--438, 2008. Google Scholar
Digital Library
- Adriaan Moors, Frank Piessens, and Martin Odersky. Parser combinators in Scala. Technical Report CW491, Katholieke Universiteit Leuven, Belgium, 2008.Google Scholar
- Adriaan Moors, Frank Piessens, and Martin Odersky. Safe type-level abstraction in scala. In Proc. of International Workshop on Foundations of Object-Oriented Languages (FOOL'08), January 2008.Google Scholar
- Nathaniel Nystrom, Stephen Chong, and Andrew C. Myers. Scalable extensibility via nested inheritance. In Proc. of OOPSLA '04, pages 99--115, October 2004. Google Scholar
Digital Library
- Nathaniel Nystrom, Xin Qi, and Andrew C. Myers. J&: Nested intersection for scalable software composition. In Proc. of OOPSLA'06, pages 21--36, 2006. Google Scholar
Digital Library
- Martin Odersky. The Scala language specification, version 2.6. EPFL. http://www.scala-lang.org/docu/files/ScalaReference.pdf, November 2007.Google Scholar
- Martin Odersky, Vincent Cremet, Christine Rockl, and Matthias Zenger. A nominal theory of objects with dependent types. In Luca Cardelli, editor, Proc. of ECOOP '03, volume 2743 of LNCS, pages 201--224, Darmstadt, Germany, July 2003.Google Scholar
- Martin Odersky and Matthias Zenger. Scalable component abstractions. In Proc. of OOPSLA '05, pages 41--57, 2005. Google Scholar
Digital Library
- Chieri Saito and Atsushi Igarashi. The essence of lightweight family polymorphism. Journal of Object Technology, 7(5):67--99, June 2008. Special Issue: Workshop on FTfJP 2007.Google Scholar
Cross Ref
- Chieri Saito and Atsushi Igarashi. Matching ThisType to subtyping. In Proceedings of the 24th Annual ACM Symposium on Applied Computing (SAC2009), pages 1851--1858, Honolulu, HI, March 2009. Google Scholar
Digital Library
- Chieri Saito, Atsushi Igarashi, and Mirko Viroli. Lightweight family polymorphism. Journal of Functional Programming, 18(3):285--331, 2008. Google Scholar
Digital Library
- Martin Steffen. Polarized Higher-Order Subtyping. PhD thesis, Technische Fakultat, Friedrich-Alexander-Universitat Erlangen-Nurnberg, November 1998.Google Scholar
- Kresten Krab Thorup and Mads Torgersen. Unifying genericity: Combining the benefits of virtual types and parameterized classes. In Proc. of 13th ECOOP (ECOOP'99), volume 1628 of LNCS, pages 186--204, Lisbon, Portugal, June 1999. Google Scholar
Digital Library
- Mads Torgersen. The expression problem revisited: Four new solutions using generics. In Proc. of ECOOP2004, volume 3086 of LNCS, pages 123--146, Oslo, Norway, June 2004.Google Scholar
- Mads Torgersen, Christian Plesner Hansen, Erik Ernst, Peter von der Ahe, Gilad Bracha, and Neal Gafter. Adding wildcards to the Java programming language. In Proc. of SAC'04, pages 1289--1296, 2004. Google Scholar
Digital Library
- Philip Wadler. The expression problem., 1998. Discussion on the Java-Genericity mailing list. Also available at http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt.Google Scholar
- Andrew K. Wright and Matthias Felleisen. A syntactic approach to type soundness. Information and Computation, 115(1):38--94, November 1994. Google Scholar
Digital Library
Index Terms
Self type constructors
Recommendations
Self type constructors
OOPSLA '09: Proceedings of the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applicationsBruce and Foster proposed the language LOOJ, an extension of Java with the notion of MyType, which represents the type of a self reference and changes its meaning along with inheritance. MyType is useful to write extensible yet type-safe classes for ...
Matching MyType to subtyping
The notion of MyType has been proposed to promote type-safe reuse of binary methods and recently extended to mutually recursive definitions. It is well known, however, that MyType does not match with subtyping well. In current type systems, type safety ...
Exact type parameterization and ThisType support
TLDI '12: Proceedings of the 8th ACM SIGPLAN workshop on Types in language design and implementationWe propose language support for binary methods and generic factory methods using ThisType. We present three new language features: (1) exact type capture which relaxes the restriction of earlier static approaches to binary methods that the run-time type ...







Comments