paperbot · PL 论文追踪

全部论文 待读 收藏

P2 High-level effect handlers in C++

C++ 中的高层效应处理器
OOPSLA 6(OOPSLA2)2022匹配度 2/10 · 该论文属于编程语言设计与实现,聚焦在 C++ 中实现高层效应处理器,与用户核心关注的静态分析、LLM/Agent、浮点程序分析、贝叶斯程序分析均无直接交叉;仅在广义 PL 方向上有弱相关。引用 14 inbox
Dan Ghica, Sam Lindley, Marcos Maroñas Bravo, Maciej Piróg
crossref: 2026-09-10

AI 速览

一句话:提出 cpp-effects 库,在带手动内存管理的 C++ 中实现带类型的高层效应处理器,并验证其性能竞争力。

本文研究如何在具有手动内存管理的命令式系统语言中支持效应处理器(effect handlers)。作者提出 cpp-effects:一个为 C++ 设计的效应处理器库,提供带类型的高层、面向对象接口。论文通过一组示例展示在 C++ 中使用效应处理器实现自定义错误处理、轻量并发和动态绑定等计算效应的编程方式,并讨论其实现细节与挑战。评估上,作者既用示例说明可用性,又将 cpp-effects 与 C++20 协程及多提示定界控制库 libmprompt 进行性能比较;结果显示,尽管存在语言限制,cpp-effects 的性能仍具竞争力,在某些情况下甚至优于现有先进方案。

问题
研究问题:如何在带手动内存管理的命令式系统编程语言(C++)中成功应用效应处理器,并提供类型安全的高层编程接口。
方法
方法:实现 cpp-effects 库,为 C++ 提供带类型的高层面向对象效应处理器接口,并通过自定义错误处理、轻量并发、动态绑定等示例探索编程模式与实现挑战。
评估
评估:通过示例展示可用性,并与 C++20 协程和 libmprompt 等先进方案进行性能对比;结果表明其性能有竞争力,某些场景甚至更优。
原文摘要(Abstract)

Effect handlers allow the programmer to implement computational effects, such as custom error handling, various forms of lightweight concurrency, and dynamic binding, inside the programming language. We introduce cpp-effects, a C++ library for effect handlers with a typed high-level, object-oriented interface. We demonstrate that effect handlers can be successfully applied in imperative systems programming languages with manual memory management. Through a collection of examples, we explore how to program effectively with effect handlers in C++, discuss the intricacies and challenges of the implementation, and show that despite its limitations, cpp-effects performance is competitive and in some cases even outperforms state-of-the-art approaches such as C++20 coroutines and the libmprompt library for multiprompt delimited control.

链接与引用

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

BibTeX
@article{paperbot1438,
  title = {High-level effect handlers in C++},
  author = {Dan Ghica and Sam Lindley and Marcos Maroñas Bravo and Maciej Piróg},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {OOPSLA2},
  year = {2022},
  doi = {10.1145/3563445}
}