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) `(dynamic-wind (lambda () #f) (lambda () ,body) (lambda () ,@unwind-forms)))
(let ((f (open-input-file "foo"))) (dynamic-wind (lambda () #f) (lambda () do something with f) (lambda () (close-input-port f))))