MLton MLTONWIKIVERSION

MLtonCont

Home Index

    signature MLTON_CONT =
       sig
          type 'a t

          val callcc: ('a t -> 'a) -> 'a
          val prepend: 'a t * ('b -> 'a) -> 'b t
          val throw: 'a t * 'a -> 'b
          val throw': 'a t * (unit -> 'a) -> 'b
       end

- `type 'a t`
  the type of continuations that expect a value of type `'a`.

- `callcc f`
  applies `f` to the current continuation. This copies the entire stack; hence, `callcc` takes time proportional to the current stack size.

- `prepend (k, f)`
  composes a function `f` with a continuation `k` to create a continuation that first does `f` and then does `k`. This is a constant time operation.

- `throw (k, v)`
  throws value `v` to continuation `k`. This copies the entire stack of `k`; hence, `throw` takes time proportional to the size of this stack.

- `throw' (k, th)`
  a generalization of throw that evaluates `th ()` in the context of `k`. Thus, for example, if `th ()` raises an exception or grabs another continuation, it will see `k`, not the current continuation.

Last edited on 2007-08-23 03:43:48 by MatthewFluet.