一句话:提出 libseff:面向 C 的基于协程的效应处理器库,可直接在 C 程序中使用且性能有竞争力。
效应处理器为异常、生成器和轻量级线程等用户自定义、可组合、可定制的计算效应提供结构化实现方式。已有面向 C 的效应处理器库多作为编译目标,而 libseff 旨在供 C 程序直接使用。为此,它偏离传统实现:以可变协程作为待完成计算的主要表示,并通过具体化效应(reified effects)避免将闭包用作处理器。论文在多种平台和基准上评估 libseff,表明其性能具有竞争力。
Effect handlers provide a structured means for implementing user-defined, composable, and customisable computational effects, ranging from exceptions to generators to lightweight threads. We introduce libseff , a novel effect handlers library for C, based on coroutines. Whereas prior effect handler libraries for C are intended primarily as compilation targets, libseff is intended to be used directly from C programs. As such, the design of libseff parts ways from traditional effect handler implementations, both by using mutable coroutines as the main representation of pending computations, and by avoiding closures as handlers by way of reified effects. We show that the performance of libseff is competitive across a range of platforms and benchmarks.
@article{Alvarez-Picallo24,
title = {Effect Handlers for C via Coroutines},
author = {Mario Alvarez-Picallo and Teodoro Freund and Dan R. Ghica and Sam Lindley},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {OOPSLA2},
year = {2024},
doi = {10.1145/3689798}
}