unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#18356: Should partial continuations capture the dynamic environment?
@ 2014-08-29 18:12 Taylan Ulrich Bayirli/Kammer
  2014-08-29 18:26 ` Taylan Ulrich Bayirli/Kammer
  2014-10-14 14:25 ` Taylan Ulrich Bayirli/Kammer
  0 siblings, 2 replies; 5+ messages in thread
From: Taylan Ulrich Bayirli/Kammer @ 2014-08-29 18:12 UTC (permalink / raw)
  To: 18356

On Guile 2.0.11:

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

In other words, when a partial continuation is called, the dynamic
environment at that call-time is in effect for the continuation, and
not the one from when the continuation was captured.

Is this behavior correct and what I'm trying to do won't work, or
should the code return 1 as I had expected?


For comparison, the following variant that uses call/cc works fine:

(define (capture-dynenv)
  ((call/cc
    (lambda (call-in-captured-dynenv)
      (lambda ()
        (lambda (proc)
          (call/cc
           (lambda (go-back)
             (call-in-captured-dynenv
              (lambda ()
                (call-with-values proc go-back)))))))))))

Taylan





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-15 16:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-29 18:12 bug#18356: Should partial continuations capture the dynamic environment? Taylan Ulrich Bayirli/Kammer
2014-08-29 18:26 ` Taylan Ulrich Bayirli/Kammer
2014-10-14 14:25 ` Taylan Ulrich Bayirli/Kammer
2014-10-14 16:48   ` Nala Ginrut
2014-10-15 16:37   ` Mark H Weaver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).