This is a goofy and or fun beginner exercise to see how call-with-current-continuation and dynamic-wind? can interact in a rather displeasing manner. What happens when you run this in the REPL? What happens when you try and break?

 (let loop ()  
     (lambda (k)  
         (lambda () #t)  
         (lambda () (let loop () (loop)))  

Note: According to R5RS,

The effect of using a captured continuation to enter or exit the dynamic extent of a call to before or after is undefined. (Those procedures are the first & third arguments, respectively.)


I've been told that it's generally a bad idea to call a continuation from the before or after thunks of dynamic-wind...

category-code category-learning-scheme