Chicken » Module (chicken continuation)

## Module (chicken continuation)

This module provides a more powerful interface for continuations than that provided by `call/cc`.

More information about this continuation API can be found in the paper http://repository.readscheme.org/ftp/papers/sw2001/feeley.pdf A Better API for first class Continuations by Marc Feeley.

### Continuations API

#### continuation-capture

continuation-capture PROCEDUREprocedure

  Creates a continuation object representing the current continuation and tail-calls PROCEDURE with this continuation as the single argument.

#### continuation?

continuation? Xprocedure

  Returns `#t` if X is a continuation object, or `#f` otherwise. Please note that this applies only to continuations created by the Continuation API, but not by call/cc, i.e.: `(call-with-current-continuation continuation?)` returns `#f`, whereas `(continuation-capture continuation?)` returns `#t`.

#### continuation-graft

continuation-graft CONT THUNKprocedure

  Calls the procedure THUNK with no arguments and the implicit continuation CONT.

#### continuation-return

continuation-return CONT VALUE ...procedure

  Returns the value(s) to the continuation CONT. `continuation-return` could be implemented like this:

      (define (continuation-return k . vals)
        (continuation-graft
          k
          (lambda () (apply values vals))))

Previous: Module (chicken condition)

Next: Module (chicken csi)