This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: consecutive 'let



On Dec 26, 2007, at 2:55 PM, Jake Miles wrote:


I've never understood why
dynamic-wind includes a 'before' function - maybe someone can
enlighten me.

Because (as Stephen also points out, I now see) you can reenter the dynamic scope of a call to the middle function through a continuation captured from call-with-current-continuation. For example:


(define captured-continuation #f)
(define inside-dynamic-wind? #f)

(define (dynamic-wind-example)
  (dynamic-wind (lambda () (set! inside-dynamic-wind? #t))
      (lambda ()
        (call-with-current-continuation
         (lambda (k)
           (set! captured-continuation k)))
        ;; evaluating (captured-continuation) resumes from here
        (cond (inside-dynamic-wind?
               (display "inside dynamic-wind")
               (newline))
              (else
               (display "not inside dynamic wind")
               (newline))))
      (lambda () (set! inside-dynamic-wind? #f))))

(dynamic-wind-example)
=> displays "inside dynamic-wind"

inside-dynamic-wind?
=> #f

(captured-continuation)
=> displays "inside dynamic-wind"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]