archives

Issue One of The Monad.Reader, monthly Haskell eZine

The first issue of The Monad.Reader is out. We'd like to hear your feedback.

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 :-)