From: Taylan Ulrich Bayirli/Kammer <taylanbayirli@gmail.com>
To: 18356@debbugs.gnu.org
Subject: bug#18356: Should partial continuations capture the dynamic environment?
Date: Fri, 29 Aug 2014 20:12:09 +0200 [thread overview]
Message-ID: <87lhq7go7a.fsf@taylan.uni.cx> (raw)
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
next reply other threads:[~2014-08-29 18:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-29 18:12 Taylan Ulrich Bayirli/Kammer [this message]
2014-08-29 18:26 ` bug#18356: Should partial continuations capture the dynamic environment? 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lhq7go7a.fsf@taylan.uni.cx \
--to=taylanbayirli@gmail.com \
--cc=18356@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).