paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Compositional embeddings of domain-specific languages

领域特定语言的组合式嵌入
OOPSLA 6(OOPSLA2)2022匹配度 2/10 · 论文研究 DSL 的嵌入方式与组合式编程,属于编程语言设计与语言特性,但未涉及静态分析、ML/Agentic 程序、浮点程序分析、贝叶斯程序分析或 LLM 与 PL 的交叉,因此与当前研究画像核心方向距离较远。引用 3 inbox
Yaozhu Sun, Utkarsh Dhandhania, Bruno C. d. S. Oliveira
crossref: 2026-09-10

AI 速览

一句话:提出组合式嵌入,在 CP 语言中兼得浅层与深层嵌入优势,支持 DSL 语言复用、模式匹配与可扩展解释。

定义领域特定语言(DSL)的一种常见方式是将它们直接嵌入宿主语言,包括浅层嵌入和深层嵌入,但二者在现有编程语言中各有取舍,实践中常需混用并引入大量代码和高级技巧。本文利用近期提出的组合编程范式和 CP 语言,提出一种新的组合式嵌入。它一方面具备浅层嵌入的多种语言复用优势,例如复用宿主语言优化、轻松添加新的 DSL 构造;另一方面又类似深层嵌入,支持对 DSL 抽象语法进行模式匹配或动态分派,包括依赖解释、变换和优化,并能新增解释。作者以文档编写 DSL ExT 为例展示组合式嵌入,该 DSL 高度灵活且可扩展,可轻松创建非平凡扩展,如生成类 wiki 文档、LaTeX 文档、矢量图或图表。最后通过三个应用评估组合式嵌入在 ExT 中的可行性。

问题
嵌入式 DSL 中浅层嵌入与深层嵌入各有取舍,难以同时获得语言复用、易扩展与对抽象语法的灵活解释/变换能力。
方法
在组合编程范式和 CP 语言中提出组合式嵌入,并用文档编写 DSL ExT 展示其灵活性和可扩展性。
评估
以 ExT 的三个应用评估组合式嵌入的可行性,并展示其支持 wiki、LaTeX、矢量图和图表等多种扩展。
原文摘要(Abstract)

A common approach to defining domain-specific languages (DSLs) is via a direct embedding into a host language. There are several well-known techniques to do such embeddings, including shallow and deep embeddings. However, such embeddings come with various trade-offs in existing programming languages. Owing to such trade-offs, many embedded DSLs end up using a mix of approaches in practice, requiring a substantial amount of code, as well as some advanced coding techniques. In this paper, we show that the recently proposed Compositional Programming paradigm and the CP language provide improved support for embedded DSLs. In CP we obtain a new form of embedding, which we call a compositional embedding, that has most of the advantages of both shallow and deep embeddings. On the one hand, compositional embeddings enable various forms of linguistic reuse that are characteristic of shallow embeddings, including the ability to reuse host-language optimizations in the DSL and add new DSL constructs easily. On the other hand, similarly to deep embeddings, compositional embeddings support definitions by pattern matching or dynamic dispatching (including dependent interpretations, transformations, and optimizations) over the abstract syntax of the DSL and have the ability to add new interpretations. We illustrate an instance of compositional embeddings with a DSL for document authoring called ExT. The DSL is highly flexible and extensible, allowing users to create various non-trivial extensions easily. For instance, ExT supports various extensions that enable the production of wiki-like documents, LaTeX documents, vector graphics or charts. The viability of compositional embeddings for ExT is evaluated with three applications.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1423,
  title = {Compositional embeddings of domain-specific languages},
  author = {Yaozhu Sun and Utkarsh Dhandhania and Bruno C. d. S. Oliveira},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {OOPSLA2},
  year = {2022},
  doi = {10.1145/3563294}
}