Subject: Should partial continuations capture the dynamic environment?

From: Taylan Ulrich Bayirli/Kammer <[email-masked]>
Date: Fri, 29 Aug 2014 20:26:47 +0200

Some more examples; this one works fine:

scheme@(guile-user)> (define (with-captured-dynenv proc)
                       (let ((tag (make-prompt-tag "dynenv-capture")))
                         (call-with-prompt
                          tag
                          (lambda ()
                            (proc (lambda (thunk)
                                    (abort-to-prompt tag thunk))))
                          (lambda (return thunk)
                            (return (thunk))))))
scheme@(guile-user)> (define param (make-parameter 0))
scheme@(guile-user)> (parameterize ((param 1))
                       (with-captured-dynenv
                        (lambda (dynenv)
                          (parameterize ((param 2))
                            (dynenv (lambda () (param)))))))
$2 = 1

But not this simpler one:

scheme@(guile-user)> (define (with-captured-dynenv proc)
                       (let ((tag (make-prompt-tag "dynenv-capture")))
                         (call-with-prompt
                          tag
                          (lambda ()
                            ((abort-to-prompt tag)))
                          (lambda (call-in-captured-dynenv)
                            (proc call-in-captured-dynenv)))))
scheme@(guile-user)> (parameterize ((param 1))
                       (with-captured-dynenv
                        (lambda (dynenv)
                          (parameterize ((param 2))
                            (dynenv (lambda () (param)))))))
$3 = 2

Taylan