Semi-automatic Defunctionalization of Continuations
Tony Garnock-Jones. February 2016.
Programmers use continuations to achieve all manner of interesting control effects (e.g. Shivers & Turon 2011). But common representations of continuations cause problems in practice in two ways. On one hand, continuations represented as functions are entirely opaque; the only available operation is to invoke the continuation. On the other hand, continuations represented as reified machine stacks expose too much information; irrelevant detail of the program's information becomes visible. In this paper, we present a design for a middle-ground. Using our new language construct, continuations are represented as censored reified machine stacks. Programmers precisely control the information and behavior associated with each frame in the continuation, allowing them the benefits of automatic continuation reification combined with the benefits of a defunctionalized representation of control as data.