paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Compiled, Extensible, Multi-language DSLs (Functional Pearl)

可编译、可扩展的多语言 DSL(函数式珍珠)
ICFP 8(ICFP)2024匹配度 2/10 · 该论文属于纯 PL/DSL 实现与编译器优化方向,讨论 Racket 的 syntax-spec 与 miniKanren 重实现,未涉及用户核心关注的 PL↔AI/LLM、静态分析、浮点程序分析或贝叶斯程序分析。仅因涉及 DSL、宏扩展与编译优化而与 PL 背景有微弱关联。引用 7 inbox
Michael Ballantyne, Mitch Gamburg, Jason Hemann
dblp: 2026-09-10crossref: 2026-09-10

AI 速览

一句话:提出 Racket 的 syntax-spec 元语言,使 DSL 实现兼得自动宏扩展与编译优化,并重新实现 miniKanren。

特定领域语言的实现通常需要在可扩展性与性能优化之间取舍:miniKanren 社区以往也在不同实现中分别探索扩展机制与优化技术。本文介绍 Racket 的新元语言 syntax-spec,它让程序员能直接实现既自动具备宏扩展能力、又能接受常规编译器优化的 DSL。作者用 syntax-spec 重新实现关系式编程 DSL miniKanren,将优化编译器与扩展机制统一在同一实现中,同时保持 Racket 与 miniKanren 之间如同浅嵌入般无缝集成。该工作以函数式珍珠形式展示如何调和 DSL 的可扩展性与编译性能,并体现多语言 DSL 的构造方法。

问题
DSL 实现应同时支持可扩展性与性能优化,但既有 miniKanren 实现将优化技术与扩展机制分开探索,难以兼得。
方法
在 Racket 中使用新的 syntax-spec 元语言实现 DSL,使其自动宏可扩展并支持常规编译优化,并用该方式重新实现 miniKanren。
评估
以新的 miniKanren 实现为例,展示优化编译器与扩展机制可在单一实现中统一,并保持 Racket 与 miniKanren 的无缝浅嵌入集成。
原文摘要(Abstract)

Implementations of domain-specific languages should offer both extensibility and performance optimizations. With the new syntax-spec metalanguage in Racket, programmers can easily create DSL implementations that are both automatically macro-extensible and subject to conventional compiler optimizations. This pearl illustrates this approach through a new implementation of miniKanren, a widely used relational programming DSL. The miniKanren community has explored, in separate implementations, optimization techniques and a wide range of extensions. We demonstrate how our new miniKanren implementation with syntax-spec reconciles these features in a single implementation that comes with both an optimizing compiler and an extension mechanism. Furthermore, programmers using the new implementation benefit from the same seamless integration between Racket and miniKanren as in existing shallow embeddings.

链接与引用

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

BibTeX
@article{BallantyneGH24,
  title = {Compiled, Extensible, Multi-language DSLs (Functional Pearl)},
  author = {Michael Ballantyne and Mitch Gamburg and Jason Hemann},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {ICFP},
  year = {2024},
  doi = {10.1145/3674627}
}