13.  Continuations  

(call-with-current-continuation procedure)

See R^4RS.

(control-point? obj)

Returns #t if obj is a control point (a continuation), #f otherwise.

(dynamic-wind thunk thunk thunk)

dynamic-wind is a generalization of the unwind-protect facility provided by many Lisp systems.
All three arguments are procedures of no arguments. In the normal case, all three thunks are applied in order. The first thunk is also applied when the body (the second thunk) is entered by the application of a control point created within the body (by means of call-with-current-continuation). Similarly, the third thunk is also applied whenever the body is exited by invocation of a control point created outside the body.

(define-macro (unwind-protect body . unwind-forms)
    (lambda () #f)
    (lambda () ,body)
    (lambda () ,@unwind-forms)))
(let ((f (open-input-file "foo")))
    (lambda () #f)
    (lambda () do something with f)
    (lambda () (close-input-port f))))

Markup created by unroff 1.0,    September 24, 1996,    net@informatik.uni-bremen.de