paperbot · PL 论文追踪

RSS

Type-Safe Compilation of Dynamic Inheritance via Merging

TOPLAS 47(4)2025
Yaozhu Sun, Xuejing Huang, Bruno C. D. S. Oliveira

尚未生成 AI 速览(可能缺少 API key 或等待下次运行补跑)。

原文摘要(Abstract)

Inheritance is a key concept in many programming languages. Dynamically typed languages, such as JavaScript, often support powerful forms of dynamic inheritance. However, dynamic inheritance poses significant challenges for static typing. Most statically typed languages only provide static inheritance to achieve type safety at the cost of flexibility. This article presents a compiler for the CP language, which is a statically typed language that supports dynamic inheritance via a merge operator and also has an expressive form of parametric polymorphism. The merge operator enables a form of multiple inheritance and first-class classes, as well as virtual classes and family polymorphism. With these features, CP allows the development of highly modular and loosely coupled components. However, the efficient compilation of CP code is non-trivial, especially if separate compilation is desired. In particular, subtyping in CP is coercive for type safety, which poses significant challenges in obtaining an efficient compilation scheme. We show how CP is compilable to languages supporting extensible records or similar data structures, where record labels are generated from types for efficient lookup on merges. The main ideas of the compilation scheme are formalized in Coq and proven to be type-safe. The concrete implementation of the CP compiler targets JavaScript, where records are modeled as JavaScript objects. We conduct an empirical evaluation with various benchmarks and evaluate the impact of several CP-specific optimizations. With our optimizations, CP can be orders of magnitude faster than with a naive compilation scheme for merges, obtaining performance on par with class-based JavaScript programs.

链接与引用

DOI 原文 ·

BibTeX
@article{paperbot3301,
  title = {Type-Safe Compilation of Dynamic Inheritance via Merging},
  author = {Yaozhu Sun and Xuejing Huang and Bruno C. D. S. Oliveira},
  journal = {ACM Transactions on Programming Languages and Systems},
  volume = {47},
  number = {4},
  year = {2025},
  doi = {10.1145/3765518}
}