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