paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Rhombus: A New Spin on Macros without All the Parentheses

Rhombus:无需满屏括号的宏新方案
OOPSLA 7(OOPSLA2)2023匹配度 2/10 · 论文属于程序语言设计与宏系统,关注中缀语法、多绑定空间和语言可扩展性;与静态分析、LLM/Agent、浮点程序分析、贝叶斯程序分析等核心方向没有直接交集,仅可作为 PL 基础工作间接参考。引用 5 inbox
Matthew Flatt, Taylor Allred, Nia Angle, Stephen De Gabrielle, Robert Bruce Findler, Jack Firth, Kiran Gopinathan, Ben Greenman, Siddhartha Kasivajhula, Alex Knauth, Jay McCarthy, Sam Phillips, Sorawee Porncharoenwase, Jens Axel Søgaard, Sam Tobin-Hochstadt
crossref: 2026-09-10

AI 速览

一句话:提出 Rhombus:在 Racket 上用中缀语法实现 Lisp 式宏与语言扩展的多绑定空间方案。

Rhombus 是构建在 Racket 上的新语言,目标是在传统中缀表示法下提供与 Racket 同等的语言可扩展性,同时避免 Lisp 式宏所依赖的大量括号。其关键方法是引入多个绑定空间,支持上下文相关的子语言,使表达式与模式匹配等上下文可复用同名但含义不同的运算符而不冲突。上下文敏感绑定还缩短了核心语言与宏设施之间的记法距离,例如重复可在绑定与表达式上下文中通用定义和使用,从而平滑过渡到元编程。此外,扩展协议支持在绑定与表达式之间传递静态信息(如类型),以将宏扩展到 Lisp 之外。实现表明这些机制能协同工作,形成连贯且用户友好的语言。

问题
如何在非 Lisp 括号语法下保留 Racket 式宏的语言可扩展性,并让宏与核心语言及静态信息协作。
方法
Rhombus 使用多个绑定空间与上下文相关绑定,支持上下文特定子语言,并在展开协议中通信静态信息。
评估
通过实现与示例展示这些机制可在实际语言中协同工作,提供实用且表达力强的宏系统。
原文摘要(Abstract)

Rhombus is a new language that is built on Racket. It offers the same kind of language extensibility as Racket itself, but using traditional (infix) notation. Although Rhombus is far from the first language to support Lisp-style macros without Lisp-style parentheses, Rhombus offers a novel synthesis of macro technology that is practical and expressive. A key element is the use of multiple binding spaces for context-specific sublanguages. For example, expressions and pattern-matching forms can use the same operators with different meanings and without creating conflicts. Context-sensitive bindings, in turn, facilitate a language design that reduces the notational distance between the core language and macro facilities. For example, repetitions can be defined and used in binding and expression contexts generally, which enables a smoother transition from programming to metaprogramming. Finally, since handling static information (such as types) is also a necessary part of growing macros beyond Lisp, Rhombus includes support in its expansion protocol for communicating static information among bindings and expressions. The Rhombus implementation demonstrates that all of these pieces can work together in a coherent and user-friendly language.

链接与引用

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

BibTeX
@article{paperbot1839,
  title = {Rhombus: A New Spin on Macros without All the Parentheses},
  author = {Matthew Flatt and Taylor Allred and Nia Angle and Stephen De Gabrielle and Robert Bruce Findler and Jack Firth and Kiran Gopinathan and Ben Greenman and Siddhartha Kasivajhula and Alex Knauth and Jay McCarthy and Sam Phillips and Sorawee Porncharoenwase and Jens Axel Søgaard and Sam Tobin-Hochstadt},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {OOPSLA2},
  year = {2023},
  doi = {10.1145/3622818}
}