Affiliation:
1. CNRS, France / Université Paris Cité, France
Abstract
Records are finite functions from keys to values. In this work we focus on two main distinct usages of records: structs and maps. The former associate different keys to values of different types, they are accessed by providing nominal keys, and trying to access a non-existent key yields an error. The latter associate all keys to values of the same type, they are accessed by providing expressions that compute a key, and trying to access a non-existent key usually yields some default value such as Null or nil. Here, we propose a type theory that covers both kinds of usage, where record
types
may associate to different types either single keys (as for structs) or sets of keys (as for maps) and where the same record
expression
can be accessed and used both in the struct-like style and in the map-like style we just described. Since we target dynamically-typed languages our type theory includes union and intersection types, characterized by a subtyping relation. We define the subtyping relation for our record types via a semantic interpretation and derive the decomposition rules to decide it, define a backtracking-free subtyping algorithm that we prove to be correct, and provide a canonical representation for record types that is used to define various type operators needed to type record operations such as selection, concatenation, and field deletion.
Publisher
Association for Computing Machinery (ACM)
Subject
Safety, Risk, Reliability and Quality,Software
Reference44 articles.
1. Ballerina. Ballerina Language Specification. https://ballerina.io/learn/ballerina-specifications/
2. Véronique Benzaken, Giuseppe Castagna, and Alain Frisch. 2003. CDuce: an XML-Centric General-Purpose Language. In ICFP ’03, 8th ACM International Conference on Functional Programming. ACM Press, Uppsala, Sweden. 51–63.
3. Practical Optional Types for Clojure
4. A modest model of records, inheritance and bounded quantification
5. A semantics of multiple inheritance
Cited by
1 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Polymorphic Type Inference for Dynamic Languages;Proceedings of the ACM on Programming Languages;2024-01-05