GNU bug report logs - #18356
Should partial continuations capture the dynamic environment?

Previous Next

Package: guile;

Reported by: Taylan Ulrich Bayirli/Kammer <taylanbayirli <at> gmail.com>

Date: Fri, 29 Aug 2014 18:13:02 UTC

Severity: normal

Tags: notabug

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Taylan Ulrich Bayirli/Kammer <taylanbayirli <at> gmail.com>
To: bug-guile <at> gnu.org
Subject: Should partial continuations capture the dynamic environment?
Date: Fri, 29 Aug 2014 20:12:09 +0200
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




This bug report was last modified 10 years and 307 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.