4.  Fluid Binding  

(fluid-let bindings body)

bindings is of the form ((variable1 init1) ...). The inits are temporarily assigned to the variables and the body is executed. The variables must be bound in an enclosing scope. When the body is exited normally or by invoking a control point, the old values of the variables are restored. In the latter case, when the control returns back to the body of the fluid-let by invocation of a control point created within the body, the bindings are changed again to the values they had when the body exited.
Examples:

((lambda (x)
  (+ x (fluid-let ((x 3)) x))) 1)     ==>  4
(fluid-let ((print-length 2))
  (write '(a b c d)))                 ==>  '(a b ...)
(define (errset thunk)
  (call-with-current-continuation
    (lambda (catch)
      (fluid-let
          ((error-handler
            (lambda msg (catch #f))))
        (list (thunk))))))

(errset (lambda () (+ 1 2)))          ==>  (3)
(errset (lambda () (/ 1 0)))          ==>  #f


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