skip to main content
10.1145/3510487.3510509acmotherconferencesArticle/Chapter ViewAbstractPublication PagesicbtaConference Proceedingsconference-collections
research-article

A Subtyping Scheme for Nominal and Structural Types Based on Class Graph Equivalence

Published: 25 February 2022 Publication History

Abstract

Subtyping and multiple inheritance are the essential features of oo and component-based programming languages, in particular with the presence of interfaces and contracts. More general, the composability of these constructs admitting the subtype relation powers the reusability, modular, flexibility and reliability of oo-based systems. While nominal classes allow annotation of user intention to the types, operations on interfaces and contracts naturally result structural constructs. Structural types are also necessary if we need the types to have value-semantics, so that they can be transferred around in distributed systems. Building a type system that allows the coexistence of nominal and structural classes, while maintaining the usual subtype relation is critical and challenging. We present a subtyping scheme that encodes a class to a directed and edge-labeled graph, which has the convenience to handle recursive types. The names of a class and its superclasses are encoded as tags to label the edges of the graph, turning the nominal construct into a structural one. This encoding allows us to unify the handling of class relations into graph relations. We define the class representation, canonical form, value-identity and subtype relation in the notion of graphs, and justify our subtyping scheme in the cases of multiple inheritance, class intersection and union. Our scheme is general, easy to implement and compatible with most of the existing oo type systems, providing a solid base for further oo language and tool development.

References

[1]
Martin Abadi and Luca Cardelli. 1996. A Theory of Objects. Springer.
[2]
Ravi P Agarwal, Maria Meehan, and Donal O’regan. 2001. Fixed point theory and applications. Vol. 141. Cambridge university press.
[3]
Davide Ancona and Andrea Corradi. 2016. Semantic subtyping for imperative object-oriented languages. ACM SIGPLAN Notices 51, 10 (2016), 568–587.
[4]
Julia Belyakova. 2019. Decidable tag-based semantic subtyping for nominal types, tuples, and unions. In Proceedings of the 21st Workshop on Formal Techniques for Java-like Programs. 1–11.
[5]
Jan Bessai, Andrej Dudenhefner, Tzu Chun Chen, Ugo De’Liguoro, Jakob Rehof, 2015. Mixin composition synthesis based on intersection types. In TLCA 2015, Vol. 38. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 76–91.
[6]
Artur Boronat. 2017. Structural model subtyping with OCL constraints. In Proceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering. 194–205.
[7]
Luca Cardelli, Simone Martini, John C Mitchell, and Andre Scedrov. 1994. An extension of system F with subtyping. Information and computation 109, 1-2 (1994), 4–56.
[8]
Giuseppe Castagna and Victor Lanvin. 2017. Gradual typing with union and intersection types. Proceedings of the ACM on Programming Languages 1, ICFP(2017), 1–28.
[9]
Benjamin Chung, Paley Li, Francesco Zappa Nardelli, and Jan Vitek. 2018. Kafka: Gradual typing for objects. In ECOOP 2018-2018 European Conference on Object-Oriented Programming.
[10]
Michael Coblenz, Reed Oei, Tyler Etzel, Paulette Koronkevich, Miles Baker, Yannick Bloem, Brad A Myers, Joshua Sunshine, and Jonathan Aldrich. 2020. Obsidian: Typestate and assets for safer blockchain programming. ACM Transactions on Programming Languages and Systems (TOPLAS) 42, 3(2020), 1–82.
[11]
Mario Coppo and Mariangiola Dezani-Ciancaglini. 1980. An extension of the basic functionality theory for the λ-calculus.Notre Dame journal of formal logic 21, 4 (1980), 685–693.
[12]
Ugo Dal Lago, Claudia Faggian, and Simona Ronchi Della Rocca. 2021. Intersection types and (positive) almost-sure termination. Proceedings of the ACM on Programming Languages 5, POPL(2021), 1–32.
[13]
Flemming M Damm. 1994. Subtyping with union types, intersection types and recursive types. In International Symposium on Theoretical Aspects of Computer Software. Springer, 687–706.
[14]
Ornela Dardha, Daniele Gorla, and Daniele Varacca. 2017. Semantic subtyping for objects and classes. Comput. J. 60, 5 (2017), 636–656.
[15]
Ugo de’Liguoro and Riccardo Treglia. 2021. Intersection types for a λ-calculus with global store. In 23rd International Symposium on Principles and Practice of Declarative Programming. 1–11.
[16]
Mariangiola Dezani-Ciancaglini, Paola Giannini, and Betti Venneri. 2019. Intersection types in Java: Back to the future. In Models, Mindsets, Meta: The What, the How, and the Why Not?Springer, 68–86.
[17]
Stephen Dolan and Alan Mycroft. 2017. Polymorphism, subtyping, and type inference in MLsub. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages. 60–72.
[18]
Thomas Ehrhard. 2020. Non-idempotent intersection types in logical form. In International Conference on Foundations of Software Science and Computation Structures. Springer, Cham, 198–216.
[19]
Wei Ke and Ka-Hou Chan. 2021. Pattern Matching Based on Object Graphs. IEEE Access (2021). https://doi.org/10.1109/access.2021.3128575
[20]
Wei Ke, Zhiming Liu, Shuling Wang, and Liang Zhao. 2013. A graph-based generic type system for object-oriented programs. Frontiers of Computer Science 7, 1 (2013), 109–134.
[21]
Luigi Liquori and Claude Stolze. 2017. A decidable subtyping logic for intersection and union types. In International Conference on Topics in Theoretical Computer Science. Springer, 74–90.
[22]
Julian Mackay, Alex Potanin, Jonathan Aldrich, and Lindsay Groves. 2019. Decidable subtyping for path dependent types. Proceedings of the ACM on Programming Languages 4, POPL(2019), 1–27.
[23]
Koar Marntirosian, Tom Schrijvers, Bruno C d S Oliveira, and Georgios Karachalias. 2020. Resolution as intersection subtyping via Modus Ponens. Proceedings of the ACM on Programming Languages 4, OOPSLA(2020), 1–30.
[24]
Aleksandr Misonizhnik and Dmitry Mordvinov. 2019. On Satisfiability of Nominal Subtyping with Variance. In 33rd European Conference on Object-Oriented Programming (ECOOP 2019). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik.
[25]
Yuki Nishida, Hiromasa Saito, Ran Chen, Akira Kawata, Jun Furuse, Kohei Suenaga, and Atsushi Igarashi. 2021. Helmholtz: A Verifier for Tezos Smart Contracts Based on Refinement Types. In International Conference on Tools and Algorithms for the Construction and Analysis of Systems. Springer, 262–280.
[26]
Benjamin C Pierce and C Benjamin. 2002. Types and programming languages. MIT press.
[27]
John C Reynolds. 1991. The coherence of languages with intersection types. In International Symposium on Theoretical Aspects of Computer Software. Springer, 675–700.
[28]
Jeremy Siek and Walid Taha. 2007. Gradual typing for objects. In European Conference on Object-Oriented Programming. Springer, 2–27.
[29]
Artem Usov and Ornela Dardha. 2020. SFJ: An Implementation of Semantic Featherweight Java. In International Conference on Coordination Languages and Models. Springer, 153–168.
[30]
Ningning Xie, Xuan Bi, and Bruno C d S Oliveira. 2018. Consistent subtyping for all. In European Symposium on Programming. Springer, 3–30.

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Other conferences
ICBTA '21: Proceedings of the 2021 4th International Conference on Blockchain Technology and Applications
December 2021
183 pages
ISBN:9781450387460
DOI:10.1145/3510487
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 25 February 2022

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. class graph
  2. distributed programming
  3. intersection type
  4. multiple inheritance
  5. nominal subtyping
  6. object-oriented language
  7. recursive type
  8. structural subtyping
  9. subtyping
  10. type equivalence
  11. union type

Qualifiers

  • Research-article
  • Research
  • Refereed limited

Funding Sources

  • Macao Polytechnic Institute, Macau SAR

Conference

ICBTA 2021

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 36
    Total Downloads
  • Downloads (Last 12 months)4
  • Downloads (Last 6 weeks)0
Reflects downloads up to 05 Mar 2025

Other Metrics

Citations

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

HTML Format

View this article in HTML Format.

HTML Format

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media