High-level effect handlers in C++
Dan R. Ghica, Sam Lindley, Marcos Maroñas Bravo, Maciej Piróg
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.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
7 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Effect Handlers for C via Coroutines cites Retrofitting effect handlers onto OCaml
- Effect Handlers for C via Coroutines cites Continuing WebAssembly with Effect Handlers
- Retrofitting effect handlers onto OCaml cites Binders by day, labels by night: effect instances via lexically scoped handlers
- Continuing WebAssembly with Effect Handlers cites Retrofitting effect handlers onto OCaml
- Algebraic Effects Meet Hoare Logic in Cubical Agda cites Retrofitting effect handlers onto OCaml
- Soundly Handling Linearity cites Retrofitting effect handlers onto OCaml
- Soundly Handling Linearity cites Continuing WebAssembly with Effect Handlers
- Soundly Handling Linearity cites Binders by day, labels by night: effect instances via lexically scoped handlers
Cited by top-tier papers7
- Continuing WebAssembly with Effect HandlersLuna Phipps-Costin, Andreas Rossberg, Arjun Guha, Daan Leijen et al.OOPSLA 2023 · 20 citations
- Soundly Handling LinearityWenhao Tang, Daniel Hillerström, Sam Lindley, J. Garrett MorrisPOPL 2024 · 8 citations
- Effect Handlers for C via CoroutinesMario Alvarez-Picallo, Teodoro Freund, Dan R. Ghica, Sam LindleyOOPSLA 2024 · 6 citations
- Ratte: Fuzzing for Miscompilations in Multi-Level Compilers Using Composable SemanticsPingshi Yu, Nicolas Wu, Alastair F. DonaldsonASPLOS 2025 · 3 citations
- Algebraic Effects Meet Hoare Logic in Cubical AgdaDonnacha Oisín Kidney, Zhixuan Yang, Nicolas WuPOPL 2024 · 2 citations
Builds on2
Related papers
- Dynamic Wind for Effect HandlersDavid Voigt, Philipp Schuster, Jonathan Immanuel BrachthäuserOOPSLA 2025
- A typed continuation-passing translation for lexical effect handlersPhilipp Schuster, Jonathan Immanuel Brachthäuser, Marius Müller, Klaus OstermannPLDI 2022 · 10 citations
- Modal Effect TypesWenhao Tang, Leo White, Stephen Dolan, Daniel Hillerström et al.OOPSLA 2025 · 4 citations
- Tracing Just-in-Time Compilation for Effects and HandlersMarcial Gaißert, Carl Friedrich Bolz-Tereick, Jonathan Immanuel BrachthäuserOOPSLA 2025
- Efficient compilation of algebraic effect handlersGeorgios Karachalias, Filip Koprivec, Matija Pretnar, Tom SchrijversOOPSLA 2021 · 9 citations
