Delimited control in OCaml, abstractly and concretely
Delimited control in OCaml, abstractly and concretely
复制标题
OCaml 中的分隔控制,抽象和具体
DOI:
10.1016/j.tcs.2012.02.025
复制
发表时间:
2012
期刊:
影响因子:
--
通讯作者:
O. Kiselyov
中科院分区:
文献类型:
--
作者:
O. Kiselyov
We describe the first implementation of multi-prompt delimited control operators in OCaml that is direct in that it captures only the needed part of the control stack. The implementation is a library that requires no changes to the OCaml compiler or run-time, so it is perfectly compatible with existing OCaml source and binary code. The library has been in fruitful practical use since 2006. We present the library as an implementation of an abstract machine derived by elaborating the definitional machine. The abstract view lets us distill a minimalistic API, scAPI, sufficient for implementing multi-prompt delimited control. We argue that a language system that supports exception and stack-overflow handling supports scAPI. With byte- and native-code OCaml systems as two examples, our library illustrates how to use scAPI to implement multi-prompt delimited control in a typed language. The approach is general and has been used to add multi-prompt delimited control to other existing language systems.