skip to main content
research-article

Self type constructors

Published:25 October 2009Publication History
Skip Abstract Section

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.

References

  1. 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 ScholarGoogle ScholarCross RefCross Ref
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarCross RefCross Ref
  5. Kim B. Bruce. Some challenging typing issues in object-oriented languages. In Proc. of WOOD'03, volume 82 of ENTCS, 2003.Google ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarCross RefCross Ref
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle Scholar
  10. Nicholas Cameron and Sophia Drossopoulou. On subtyping, wildcards, and existential types. In Proc. of FTfJP, Genoa, Italy, July 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. Erik Ernst. Family polymorphism. In Proc. of ECOOP 2001, volume 2072 of LNCS, pages 303--326, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Erik Ernst. Higher-order hierarchies. In Proc. of ECOOP 2003, volume 2743 of LNCS, pages 303--328, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  17. Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Sotfware. Addison-Wesley, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. Paul Jolly, Sophia Drossopoulou, Christopher Anderson, and Klaus Ostermann. Simple dependent types: Concord. In Proc. of FTfJP 2004, June 2004.Google ScholarGoogle Scholar
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. Erik Meijer. Confessions of a used programming language salesman. In Proc. of OOPSLA, pages 677--694, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Bertrand Meyer. Genericity versus inheritance. In Proc. of OOPSLA, pages 391--405, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Adriaan Moors, Frank Piessens, and Martin Odersky. Generics of a higher kind. In Proc. of OOPSLA (OOPSLA'08), pages 423--438, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Adriaan Moors, Frank Piessens, and Martin Odersky. Parser combinators in Scala. Technical Report CW491, Katholieke Universiteit Leuven, Belgium, 2008.Google ScholarGoogle Scholar
  29. 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 ScholarGoogle Scholar
  30. Nathaniel Nystrom, Stephen Chong, and Andrew C. Myers. Scalable extensibility via nested inheritance. In Proc. of OOPSLA '04, pages 99--115, October 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. Martin Odersky. The Scala language specification, version 2.6. EPFL. http://www.scala-lang.org/docu/files/ScalaReference.pdf, November 2007.Google ScholarGoogle Scholar
  33. 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 ScholarGoogle Scholar
  34. Martin Odersky and Matthias Zenger. Scalable component abstractions. In Proc. of OOPSLA '05, pages 41--57, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. 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 ScholarGoogle ScholarCross RefCross Ref
  36. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  37. Chieri Saito, Atsushi Igarashi, and Mirko Viroli. Lightweight family polymorphism. Journal of Functional Programming, 18(3):285--331, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Martin Steffen. Polarized Higher-Order Subtyping. PhD thesis, Technische Fakultat, Friedrich-Alexander-Universitat Erlangen-Nurnberg, November 1998.Google ScholarGoogle Scholar
  39. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  40. 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 ScholarGoogle Scholar
  41. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  42. 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 ScholarGoogle Scholar
  43. Andrew K. Wright and Matthias Felleisen. A syntactic approach to type soundness. Information and Computation, 115(1):38--94, November 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Self type constructors

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 44, Issue 10
        OOPSLA '09
        October 2009
        554 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1639949
        Issue’s Table of Contents
        • cover image ACM Conferences
          OOPSLA '09: Proceedings of the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applications
          October 2009
          590 pages
          ISBN:9781605587660
          DOI:10.1145/1640089

        Copyright © 2009 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 25 October 2009

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!