The CONT signature


Synopsis

signature CONT
structure SMLofNJ.Cont : CONT

Interface

type 'a cont
val callcc : ('a cont -> 'a) -> 'a
val throw : 'a cont -> 'a -> 'b
val isolate : ('a -> unit) -> 'a cont
type 'a control_cont
val capture : ('a control_cont -> 'a) -> 'a
val escape : 'a control_cont -> 'a -> 'b

Description

type 'a cont
The type of continuations accepting arguments of type 'a

callcc f
Apply f to the "current continuation". If f invokes this continuation with argument x, it is as if (callcc f) had returned x as a result.

throw k a
Invoke continuation k with argument a.

isolate f x
Discard all live data from the calling context (except what is reachable from f or x), then call f(x), then exit. This may use much less memory then something like f(x) before exit().

type 'a control_cont
The type of "primitive" continuations accepting arguments of type 'a. Unlike an ordinary continuation cont, a control_cont does not remember the exception-handler of its creator.

capture f
Apply f to the "current continuation". If f invokes this continuation with argument x, it is as if (capture f) had returned x as a result, except that the exception-handler is not properly restored (it is still that of the invoker).

escape k a
Invoke primitive continuation k with argument a, which is like returning from the original capture except that the exception handler is that of whoever called escape k a.