High-Level Effect Handlers in C++

Dan Ghica, Sam Lindley, Marcos Maroñas Bravo, Maciej Piróg

Research output: Contribution to journalArticlepeer-review

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.
Original languageEnglish
Article number183
Number of pages29
JournalProceedings of the ACM on Programming Languages
Volume6
Issue numberOOPSLA2
DOIs
Publication statusAccepted/In press - 1 Sep 2022
EventConference on Object-Oriented Programming Systems, Languages, and Applications 2022 - Auckland, New Zealand
Duration: 5 Dec 202210 Dec 2022

Keywords

  • Effect handlers
  • algebraic effects
  • lightweight concurrency
  • context switching

Fingerprint

Dive into the research topics of 'High-Level Effect Handlers in C++'. Together they form a unique fingerprint.

Cite this