From: Andy Wingo <wingo@pobox.com>
To: Yi DAI <plm.day@gmail.com>
Cc: guile-user@gnu.org
Subject: Re: A question on a piece of code written using call/cc
Date: Wed, 01 Sep 2010 08:35:48 -0700 [thread overview]
Message-ID: <m3bp8hv5m3.fsf@unquote.localdomain> (raw)
In-Reply-To: <AANLkTimtD1_hvLqS4tkrwXONuVBdtU=qAYJ12oGt1HrX@mail.gmail.com> (Yi DAI's message of "Wed, 1 Sep 2010 12:10:52 +0800")
Hi Yi,
On Tue 31 Aug 2010 21:10, Yi DAI <plm.day@gmail.com> writes:
> (let ((n 0)
> (c (call/cc (lambda (k) k))))
> (display n)
> (newline)
> (set! n (+ n 1))
> (c c))
>
> What I wanna do is try to print out the sequence of natural numbers
> using call/cc. On Guile, it works well. But other implementations
> (Chicken, Bigloo, Racket) all print out (an infinite sequence of) 0. I
> am puzzled. Any idea?
Guile from master returns a sequence of zeros as well. I'm not sure why
older Guile behaves differently.
I think in any case for your program to be correct, you need to use let*
instead of let.
Andy
--
http://wingolog.org/
prev parent reply other threads:[~2010-09-01 15:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-01 4:10 A question on a piece of code written using call/cc Yi DAI
2010-09-01 15:35 ` Andy Wingo [this message]
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=m3bp8hv5m3.fsf@unquote.localdomain \
--to=wingo@pobox.com \
--cc=guile-user@gnu.org \
--cc=plm.day@gmail.com \
/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).