Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Semantic subtyping for imperative object-oriented languages

Published: 19 October 2016 Publication History

Abstract

Semantic subtyping is an approach for defining sound and complete procedures to decide subtyping for expressive types, including union and intersection types; although it has been exploited especially in functional languages for XML based programming, recently it has been partially investigated in the context of object-oriented languages, and a sound and complete subtyping algorithm has been proposed for record types, but restricted to immutable fields, with union and recursive types interpreted coinductively to support cyclic objects. In this work we address the problem of studying semantic subtyping for imperative object-oriented languages, where fields can be mutable; in particular, we add read/write field annotations to record types, and, besides union, we consider intersection types as well, while maintaining coinductive interpretation of recursive types. In this way, we get a richer notion of type with a flexible subtyping relation, able to express a variety of type invariants useful for enforcing static guarantees for mutable objects. The addition of these features radically changes the defi- nition of subtyping, and, hence, the corresponding decision procedure, and surprisingly invalidates some subtyping laws that hold in the functional setting. We propose an intuitive model where mutable record val- ues contain type information to specify the values that can be correctly stored in fields. Such a model, and the correspond- ing subtyping rules, require particular care to avoid circularity between coinductive judgments and their negations which, by duality, have to be interpreted inductively. A sound and complete subtyping algorithm is provided, together with a prototype implementation.

Supplementary Material

Auxiliary Archive (p568-ancona-s.zip)
The archive contains a directory with the Prolog implementation of the subtyping algorithm and the image of a virtual machine that can be used to run it.

References

[1]
M. Abadi and L. Cardelli. A Theory of Objects. Monographs in Computer Science. Springer, 1996.
[2]
P. Aczel. An introduction to inductive definitions. In J. Barwise, editor, Handbook of Mathematical logic. North Holland, 1977.
[3]
J. Altidor, C. Reichenbach, and Y. Smaragdakis. Java wildcards meet definition-site variance. In ECOOP’12, pages 509–534, 2012.
[4]
D. Ancona and A. Corradi. Sound and complete subtyping between coinductive types for object-oriented languages. In ECOOP 2014 - Object-Oriented Programming - 28th European Conference, volume 8586 of Lecture Notes in Computer Science, pages 282–307. Springer, 2014.
[5]
D. Ancona and A. Corradi. Semantic subtyping between coinductive mutable record types with unions and intersections. In Italian Conference on Theoretical Computer Science (ICTCS 2015), 2015. On-line proceedings.
[6]
D. Ancona and G. Lagorio. Coinductive type systems for object-oriented languages. In S. Drossopoulou, editor, ECOOP 2009 - Object-Oriented Programming, volume 5653 of LNCS, pages 2–26. Springer, 2009. ISBN 978-3-642-03012-3.
[7]
C. Anderson, P. Giannini, and S. Drossopoulou. Towards type inference for javascript. In ECOOP 2005, pages 428–452, 2005.
[8]
F. Barbanera, M. Dezani-Ciancaglini, and U. De’Liguoro. Intersection and union types: Syntax and semantics. Information and Computation, 119(2):202–230, 1995.
[9]
M. Bonsangue, J. Rot, D. Ancona, F. de Boer, and J. Rutten. A coalgebraic foundation for coinductive union types. In ICALP 2014 - 41st International Colloquium on Automata, Languages and Programming, pages 62–73, 2014.
[10]
N. Cameron, S. Drossopoulou, and E. Ernst. A model for Java with wildcards. In ECOOP 2008, pages 2–26, 2008.
[11]
G. Castagna, R. De Nicola, and D. Varacca. Semantic subtyping for the π-calculus. Theoretical Computer Science, 398 (1-3):217–242, 2008.
[12]
G. Castagna, K. Nguyen, Z. Xu, H. Im, S. Lenglet, and L. Padovani. Polymorphic functions with set-theoretic types: part 1: syntax, semantics, and evaluation. In POPL ’14, pages 5–18, 2014.
[13]
G. Castagna, K. Nguyen, Z. Xu, and P. Abate. Polymorphic functions with set-theoretic types: Part 2: Local type inference and type reconstruction. In POPL 2015, pages 289–302, 2015.
[14]
G. Castagna, T. Petrucciani, and K. Nguyen. Set-theoretic types for polymorphic variants. In ICFP 2016, 2016. To appear.
[15]
B. Courcelle. Fundamental properties of infinite trees. Theoretical Computer Science, 25:95–169, 1983.
[16]
M. Fähndrich and K. R. M. Leino. Declaring and checking non-null types in an object-oriented language. In OOPSLA 2003, pages 302–312, 2003.
[17]
A. Frisch, G. Castagna, and V. Benzaken. Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. J. ACM, 55(4), 2008.
[18]
J. Gil and I. Maman. Whiteoak: Introducing structural typing into Java. In OOPSLA ’08, 2008.
[19]
B. Hackett and S. Guo. Fast and precise hybrid type inference for javascript. In PLDI ’12, pages 239–250, 2012.
[20]
P. Heidegger and P. Thiemann. Recency types for analyzing scripting languages. In ECOOP 2010, pages 200–224, 2010.
[21]
H. Hosoya and B. C. Pierce. XDuce: A statically typed XML processing language. ACM Trans. Internet Techn., 3(2):117– 148, 2003.
[22]
A. Igarashi and H. Nagira. Union types for object-oriented programming. Journ. of Object Technology, 6(2):47–68, 2007.
[23]
T. Jones, M. Homer, and J. Noble. Brand Objects for Nominal Typing. In ECOOP 2015, pages 198–221, 2015.
[24]
V. Kashyap, J. Sarracino, J. Wagner, B. Wiedermann, and B. Hardekopf. Type refinement for static analysis of javascript. In DLS’13, pages 17–26, 2013.
[25]
B. Lerner, J. Politz, A. Guha, and S. Krishnamurthi. Tejas: retrofitting type systems for javascript. In DLS’13, pages 1–16, 2013.
[26]
X. Leroy and H. Grall. Coinductive big-step operational semantics. Information and Computation, 207:284–304, 2009.
[27]
D. Malayeri and J. Aldrich. Integrating nominal and structural subtyping. In ECOOP 2008, pages 260–284, 2008.
[28]
L. Simon, A. Bansal, A. Mallya, and G. Gupta. Co-logic programming: Extending logic programming with coinduction. In Automata, Languages and Programming, 34th International Colloquium, ICALP 2007, pages 472–483, 2007.
[29]
M. Torgersen, E. Ernst, C. P. Hansen, P. von der Ahé, G. Bracha, and N. M. Gafter. Adding wildcards to the Java programming language. Journal of Object Technology, 3(11):97–116, 2004.
[30]
T. Wang and S. F. Smith. Precise constraint-based type inference for Java. In ECOOP’01 - European Conference on Object-Oriented Programming, volume 2072, pages 99–117. Springer, 2001.

Cited By

View all
  • (2021)A Subtyping Scheme for Nominal and Structural Types Based on Class Graph EquivalenceProceedings of the 2021 4th International Conference on Blockchain Technology and Applications10.1145/3510487.3510509(151-157)Online publication date: 17-Dec-2021
  • (2020)Can determinism and compositionality coexist in RML?Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.322.4322(13-32)Online publication date: 27-Aug-2020
  • (2020)SFJ: An Implementation of Semantic Featherweight JavaCoordination Models and Languages10.1007/978-3-030-50029-0_10(153-168)Online publication date: 10-Jun-2020
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 51, Issue 10
OOPSLA '16
October 2016
915 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/3022671
Issue’s Table of Contents
  • cover image ACM Conferences
    OOPSLA 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications
    October 2016
    915 pages
    ISBN:9781450344449
    DOI:10.1145/2983990
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 the author(s) 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: 19 October 2016
Published in SIGPLAN Volume 51, Issue 10

Check for updates

Author Tags

  1. Read/Write Field Annotations
  2. Semantic Subtyp- ing
  3. Structural Types for Objects

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)14
  • Downloads (Last 6 weeks)0
Reflects downloads up to 25 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2021)A Subtyping Scheme for Nominal and Structural Types Based on Class Graph EquivalenceProceedings of the 2021 4th International Conference on Blockchain Technology and Applications10.1145/3510487.3510509(151-157)Online publication date: 17-Dec-2021
  • (2020)Can determinism and compositionality coexist in RML?Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.322.4322(13-32)Online publication date: 27-Aug-2020
  • (2020)SFJ: An Implementation of Semantic Featherweight JavaCoordination Models and Languages10.1007/978-3-030-50029-0_10(153-168)Online publication date: 10-Jun-2020
  • (2019)Decidable tag-based semantic subtyping for nominal types, tuples, and unionsProceedings of the 21st Workshop on Formal Techniques for Java-like Programs10.1145/3340672.3341115(1-11)Online publication date: 15-Jul-2019
  • (2018)Empowering union and intersection types with integrated subtypingProceedings of the ACM on Programming Languages10.1145/32764822:OOPSLA(1-29)Online publication date: 24-Oct-2018
  • (2017)Proceedings of the First Workshop on Coalgebra, Horn Clause Logic Programming and TypesElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.258.6258(70-71)Online publication date: 13-Sep-2017
  • (2017)Structural Resolution for Abstract Compilation of Object-Oriented LanguagesElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.258.2258(19-35)Online publication date: 13-Sep-2017
  • (2017)Fast and precise type checking for JavaScriptProceedings of the ACM on Programming Languages10.1145/31338721:OOPSLA(1-30)Online publication date: 12-Oct-2017

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media