Lexical Effect Handlers, Directly
Lexically scoping effect handlers is a language-design idea that equips algebraic effects with a modular semantics: it enables local-reasoning principles without giving up on the control-flow expressiveness that makes effect handlers powerful. However, we observe that existing implementations risk incurring costs akin to the run-time search for dynamically scoped handlers. This paper presents a compilation strategy for lexical effect handlers, adhering to the lexical scoping principle and targeting a language with low-level control over stack layout. Key aspects of this approach are formalized and proven correct. We embody the ideas in a language called L exa : the L exa compiler translates high-level effect handling to low-level stack switching. We evaluate the L exa compiler on a set of benchmarks; the results suggest that it generates efficient code, reducing running-time complexity from quadratic to linear in some cases.
Authors
- Yizhou Zhang (ORCID: https://orcid.org/0000-0002-8206-4694)
- Edward Lee (ORCID: https://orcid.org/0000-0001-7057-0912)
- Cong Ma (ORCID: https://orcid.org/0009-0005-0842-4697)
- Zhaoyi Ge
Institutions
- University of Waterloo (CA)
Publication Details
- Journal
- Proceedings of the ACM on Programming Languages
- Published
- 2024-10-08
- DOI
- https://doi.org/10.1145/3689770
- Citations
- 5
- Primary Topic
- Logic, programming, and type systems
- Type
- article
- Field-Weighted Citation Impact
- 1.74