Delimited control in OCaml, abstractly and concretely: system description

  • Authors:
  • Oleg Kiselyov

  • Affiliations:
  • FNMOC

  • Venue:
  • FLOPS'10 Proceedings of the 10th international conference on Functional and Logic Programming
  • Year:
  • 2010

Quantified Score

Hi-index 0.00

Visualization

Abstract

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 code and byte-code. The library has been in fruitful practical use for four years. 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 . Our library illustrates how to use scAPI to implement multi-prompt delimited control in a typed language. The approach is general and can be used to add multi-prompt delimited control to other existing language systems.