super-Charging Object-Oriented Programming Through Precise Typing of Open Recursion

Authors Andong Fan , Lionel Parreaux



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2023.11.pdf
  • Filesize: 1.05 MB
  • 28 pages

Document Identifiers

Author Details

Andong Fan
  • The Hong Kong University of Science and Technology (HKUST), Hong Kong, China
Lionel Parreaux
  • The Hong Kong University of Science and Technology (HKUST), Hong Kong, China

Acknowledgements

We thank the anonymous reviewers, Yaozhu Sun, and Marco Servetto for their helpful comments, as well as Cunyuan Gao for his help with the implementation. This work follows up on concepts previously presented by the first author as a research abstract [Fan, 2022].

Cite As Get BibTex

Andong Fan and Lionel Parreaux. super-Charging Object-Oriented Programming Through Precise Typing of Open Recursion. In 37th European Conference on Object-Oriented Programming (ECOOP 2023). Leibniz International Proceedings in Informatics (LIPIcs), Volume 263, pp. 11:1-11:28, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2023) https://doi.org/10.4230/LIPIcs.ECOOP.2023.11

Abstract

We present a new variation of object-oriented programming built around three simple and orthogonal constructs: classes for storing object state, interfaces for expressing object types, and mixins for reusing and overriding implementations. We show that the latter can be made uniquely expressive by leveraging a novel feature that we call precisely-typed open recursion. This features uses "this" and "super" annotations to express the requirements of any given partial method implementation on the types of respectively the current object and the inherited definitions. Crucially, the fact that mixins do not introduce types nor subtyping relationships means they can be composed even when the overriding and overridden methods have incomparable types. Together with advanced type inference and structural typing support provided by the MLscript programming language, we show that this enables an elegant and powerful solution to the Expression Problem.

Subject Classification

ACM Subject Classification
  • Software and its engineering → Object oriented languages
Keywords
  • Object-Oriented Programming
  • the Expression Problem
  • Open Recursion

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Kim Barrett, Bob Cassels, Paul Haahr, David A. Moon, Keith Playford, and P. Tucker Withington. A monotonic superclass linearization for dylan. In Proceedings of the 11th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA '96, pages 69-82, New York, NY, USA, 1996. Association for Computing Machinery. URL: https://doi.org/10.1145/236337.236343.
  2. Lorenzo Bettini, Ferruccio Damiani, Ina Schaefer, and Fabio Strocco. Traitrecordj: A programming language with traits and records. Science of Computer Programming, 78(5):521-541, 2013. Special section: Principles and Practice of Programming in Java 2009/2010 & Special section: Self-Organizing Coordination. URL: https://doi.org/10.1016/j.scico.2011.06.007.
  3. Gilad Bracha and William Cook. Mixin-based inheritance. In Proceedings of the European Conference on Object-Oriented Programming on Object-Oriented Programming Systems, Languages, and Applications, OOPSLA/ECOOP '90, pages 303-311, New York, NY, USA, 1990. Association for Computing Machinery. URL: https://doi.org/10.1145/97945.97982.
  4. Jacques Carette, Oleg Kiselyov, and Chung-chieh Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. J. Funct. Program., 19(5):509-543, September 2009. URL: https://doi.org/10.1017/S0956796809007205.
  5. Giuseppe Castagna, Tommaso Petrucciani, and Kim Nguyen. Set-theoretic types for polymorphic variants. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, pages 378-391, Nara, Japan, September 2016. Association for Computing Machinery. URL: https://doi.org/10.1145/2951913.2951928.
  6. William R. Cook. On understanding data abstraction, revisited. In Proceedings of the 24th ACM SIGPLAN Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA '09, pages 557-572, New York, NY, USA, 2009. Association for Computing Machinery. URL: https://doi.org/10.1145/1640089.1640133.
  7. William R. Cook, Walter Hill, and Peter S. Canning. Inheritance is not subtyping. In Proceedings of the 17th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '90, pages 125-135, New York, NY, USA, 1989. Association for Computing Machinery. URL: https://doi.org/10.1145/96709.96721.
  8. Ferruccio Damiani, Reiner Hähnle, Eduard Kamburjan, and Michael Lienhardt. A unified and formal programming model for deltas and traits. In Marieke Huisman and Julia Rubin, editors, Fundamental Approaches to Software Engineering, pages 424-441, Berlin, Heidelberg, 2017. Springer Berlin Heidelberg. Google Scholar
  9. Erik Ernst, Klaus Ostermann, and William R. Cook. A virtual class calculus. In Conference Record of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '06, pages 270-282, New York, NY, USA, 2006. Association for Computing Machinery. URL: https://doi.org/10.1145/1111037.1111062.
  10. Andong Fan. Simple extensible programming through precisely-typed open recursion. In Companion Proceedings of the 2022 ACM SIGPLAN International Conference on Systems, Programming, Languages, and Applications: Software for Humanity, SPLASH Companion 2022, pages 54-56, New York, NY, USA, 2022. Association for Computing Machinery. URL: https://doi.org/10.1145/3563768.3563951.
  11. Robert Bruce Findler and Matthew Flatt. Modular object-oriented programming with units and mixins. In Proceedings of the Third ACM SIGPLAN International Conference on Functional Programming, ICFP '98, pages 94-104, New York, NY, USA, 1998. Association for Computing Machinery. URL: https://doi.org/10.1145/289423.289432.
  12. Matthew Flatt, Robert Bruce Findler, and Matthias Felleisen. Scheme with classes, mixins, and traits. In Naoki Kobayashi, editor, Programming Languages and Systems, pages 270-289, Berlin, Heidelberg, 2006. Springer Berlin Heidelberg. Google Scholar
  13. Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. Classes and mixins. In Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '98, pages 171-183, New York, NY, USA, 1998. Association for Computing Machinery. URL: https://doi.org/10.1145/268946.268961.
  14. Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. A Programmer’s Reduction Semantics for Classes and Mixins, pages 241-269. Springer Berlin Heidelberg, Berlin, Heidelberg, 1999. URL: https://doi.org/10.1007/3-540-48737-9_7.
  15. Jacques Garrigue. Programming with polymorphic variants. In In ACM Workshop on ML, 1998. URL: https://caml.inria.fr/pub/papers/garrigue-polymorphic_variants-ml98.pdf.
  16. Jacques Garrigue. Code reuse through polymorphic variants. In In Workshop on Foundations of Software Engineering, 2000. URL: https://www.math.nagoya-u.ac.jp/~garrigue/papers/variant-reuse.pdf.
  17. David S. Goldberg, Robert Bruce Findler, and Matthew Flatt. Super and inner: Together at last! In Proceedings of the 19th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA '04, pages 116-129, New York, NY, USA, 2004. Association for Computing Machinery. URL: https://doi.org/10.1145/1028976.1028987.
  18. Robert Griesemer, Raymond Hu, Wen Kokke, Julien Lange, Ian Lance Taylor, Bernardo Toninho, Philip Wadler, and Nobuko Yoshida. Featherweight go. Proc. ACM Program. Lang., 4(OOPSLA), November 2020. URL: https://doi.org/10.1145/3428217.
  19. Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. Featherweight java: A minimal core calculus for java and gj. ACM Trans. Program. Lang. Syst., 23(3):396-450, May 2001. URL: https://doi.org/10.1145/503502.503505.
  20. Guillaume Martres. Pathless scala: A calculus for the rest of scala. In Proceedings of the 12th ACM SIGPLAN International Symposium on Scala, SCALA 2021, pages 12-21, New York, NY, USA, 2021. Association for Computing Machinery. URL: https://doi.org/10.1145/3486610.3486894.
  21. Keiko Nakata and Jacques Garrigue. Recursive modules for programming. In Proceedings of the Eleventh ACM SIGPLAN International Conference on Functional Programming, ICFP '06, pages 74-86, New York, NY, USA, 2006. Association for Computing Machinery. URL: https://doi.org/10.1145/1159803.1159813.
  22. Martin Odersky, Philippe Altherr, Vincent Cremet, Burak Emir, Sebastian Maneth, Stéphane Micheloud, Nikolay Mihaylov, Michel Schinz, Erik Stenman, and Matthias Zenger. An overview of the scala programming language, 2004. Google Scholar
  23. Bruno C. d. S. Oliveira and William R. Cook. Extensibility for the masses: Practical extensibility with object algebras. In Proceedings of the 26th European Conference on Object-Oriented Programming, ECOOP'12, pages 2-27, Berlin, Heidelberg, 2012. Springer-Verlag. URL: https://doi.org/10.1007/978-3-642-31057-7_2.
  24. Bruno C.d.S. Oliveira, Adriaan Moors, and Martin Odersky. Type classes as objects and implicits. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA '10, pages 341-360, New York, NY, USA, 2010. Association for Computing Machinery. URL: https://doi.org/10.1145/1869459.1869489.
  25. Lionel Parreaux. The ultimate conditional syntax. ML Family Workshop, 2022. URL: https://icfp22.sigplan.org/details/mlfamilyworkshop-2022-papers/6/The-Ultimate-Conditional-Syntax.
  26. Lionel Parreaux and Chun Yin Chau. MLstruct: Principal type inference in a boolean algebra of structural types. Proc. ACM Program. Lang., 6(OOPSLA2), October 2022. URL: https://doi.org/10.1145/3563304.
  27. Simon Peyton Jones. Haskell 98 language and libraries: the revised report. Journal of Functional Programming, 13, January 2003. Google Scholar
  28. Ina Schaefer, Lorenzo Bettini, Viviana Bono, Ferruccio Damiani, and Nico Tanzarella. Delta-oriented programming of software product lines. In Jan Bosch and Jaejoon Lee, editors, Software Product Lines: Going Beyond, pages 77-91, Berlin, Heidelberg, 2010. Springer Berlin Heidelberg. Google Scholar
  29. Nathanael Schärli, Stéphane Ducasse, Oscar Nierstrasz, and Andrew P. Black. Traits: Composable units of behaviour. In Luca Cardelli, editor, ECOOP 2003 - Object-Oriented Programming, pages 248-274, Berlin, Heidelberg, 2003. Springer Berlin Heidelberg. Google Scholar
  30. Alan Snyder. Encapsulation and inheritance in object-oriented programming languages. In Conference Proceedings on Object-Oriented Programming Systems, Languages and Applications, OOPSLA '86, pages 38-45, New York, NY, USA, 1986. Association for Computing Machinery. URL: https://doi.org/10.1145/28697.28702.
  31. Yaozhu Sun, Utkarsh Dhandhania, and Bruno C. d. S. Oliveira. Compositional embeddings of domain-specific languages. Proc. ACM Program. Lang., 6(OOPSLA2), October 2022. URL: https://doi.org/10.1145/3563294.
  32. Andrew K. Wright. Simple imperative polymorphism. LISP and Symbolic Computation, 8(4):343-355, December 1995. URL: https://doi.org/10.1007/BF01018828.
  33. Matthias Zenger and Martin Odersky. Extensible algebraic datatypes with defaults. In Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming, ICFP '01, pages 241-252, New York, NY, USA, 2001. Association for Computing Machinery. URL: https://doi.org/10.1145/507635.507665.
  34. Weixin Zhang, Yaozhu Sun, and Bruno C. D. S. Oliveira. Compositional programming. ACM Trans. Program. Lang. Syst., 43(3), September 2021. URL: https://doi.org/10.1145/3460228.
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail