modules, but thunk? requires loading (system vm debug). This is in ;; contrast to the open-coded version of dynamic-wind, which does ;; currently insert an eager thunk? check (but often optimizes it ;; out). Not sure what the right thing to do is here -- make thunk? ;; callable before modules are loaded, live with this inconsistency, ;; or remove the thunk? check from the compiler? Questions, ;; questions. #; (unless (thunk? out) (scm-error 'wrong-type-arg "dynamic-wind" "Not a thunk: ~S" (list out) #f)) (in) ((@@ primitive wind) in out) (call-with-values thunk (lambda vals ((@@ primitive unwind)) (out) (apply values vals)))) (define (with-fluid* fluid val thunk) "Set @var{fluid} to @var{value} temporarily, and call @var{thunk}. @var{thunk} must be a procedure of no arguments." ((@@ primitive push-fluid) fluid val) (call-with-values thunk (lambda vals ((@@ primitive pop-fluid)) (apply values vals)))) (define (with-dynamic-state state thunk) "Call @var{proc} while @var{state} is the current dynamic state object. @var{thunk} must be a procedure of no arguments." ((@@ primitive push-dynamic-state) state) (call-with-values thunk (lambda vals ((@@ primitive pop-dynamic-state)) (apply values vals))))