Linearly Used Continuations

Linearly Used Continuations

Continuations are the raw material of control. They can
be used to explain a wide variety of control behaviours,
including calling/returning (procedures), raising/handling
(exceptions), labelled jumping (goto statements), process
switching (coroutines), and backtracking. In the most powerful
form, represented by callcc and its cousins, the programmer
can manipulate continuations as first-class values.
It can be argued, however, that unrestricted use of continuations,
especially when combined with state, can give rise
to intractable higher-order spaghetti code. Hence, few languages
give the user direct, reified, access to continuations;
rather, they are "behind the scenes", implementing other
control behaviours, and their use is highly stylised.
But just what is this stylised usage? Remarkably, as we
will argue, in many forms of control, continuations are used
linearly. This is true for a wide range of effects, including
procedure call and return, exceptions, goto statements, and
coroutines.

I feel this is related to the The pi-Calculus in Direct Style, in the sense that it analyzes cases when you do not want full power of first-class continuations or CPS. This is just a vague feeling and not a scientific remark. Therefore, it's not a story, either :-)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Representing Control in the Presence of One-Shot Continuations

Representing Control in the Presence of One-Shot Continuations

Existing continuation mechanisms, such as call/cc, allow a captured continuation to be invoked multiple times. Some copying is necessary to enable a continuation to be invoked more than once. We note, however, that the vast majority of continuations are, in fact, invoked only once, and we introduce a new mechanism, one-shot continuations that eliminates all continuation-related overhead due to copying. We also explain how one-shot continuations interact with traditional multi-shot continuations and stack overflow. In addition, we present benchmark results comparing the performance of one-shot, multi-shot, and heap-based continuations for applications that range from continuation intensive programs to programs that have no explicit continuation operations.