Shift control

Nursing Standard · 2002

Delimited control operators abound, but their relationships are illunderstood, and it remains unclear which (if any) to consider canonical. Although all delimited control operators ever proposed can be implemented using undelimited continuations and mutable state, Gasbichler and Sperber [28] showed that an implementation that does not rely on undelimited continuations can be much more efficient. Unfortunately, they only implemented Felleisen’s control and prompt [18, 19, 21, 22, 49] and (from there) Danvy and Filinski’s shift and reset [11‐13], not other proposed operators with which an expression may capture its context beyond an arbitrary number of dynamically enclosing delimiters. We show that shift and reset can macro-express control and prompt, as well as the other operators, without capturing undelimited continuations or keeping mutable state. This translation is previously unknown in the literature. As a consequence, research on implementing shift and reset, such as Gasbichler and Sperber’s, transfers to the other operators. Moreover, we treat all these operators by extending a standard CPS transform (defying some skepticism in the literature whether such a treatment exists), so they can be incorporated into CPS-based language implementations.

Read the paper · More papers on PaperTik