From: Matt Hellige <matt@immute.net>
Subject: Re: Continuations: possible newbie question
Date: Wed, 18 Dec 2002 12:14:10 -0600 [thread overview]
Message-ID: <20021218121410.A24945@metro.immute.net> (raw)
In-Reply-To: <E18OhyJ-0008VJ-00@giblet.glug.org>; from ttn@giblet.glug.org on Wed, Dec 18, 2002 at 09:27:03AM -0800
[Thien-Thi Nguyen <ttn@giblet.glug.org>]
>
> is this due to a bug in guile,
>
> perhaps. here is what i see:
>
> guile> (version)
> "1.4.1.93"
> guile> (load "cwcc.scm") ; as posted
> guile> (exec-binding bind)
> "escaped"
> guile> (done-reading "hi")
> hi
> guile>
>
Well, at this point it definitely seems to be a bug. I tried it in MIT
Scheme as well, although I had to change my example not to use
exceptions. Here's my new code snippet:
(define call/cc call-with-current-continuation)
(define cont #f)
(define escape #f)
(define (make-escape)
(if (call/cc (lambda (c) (set! escape (lambda () (c #t))) #f))
(begin
(display "escaped")
(newline))
(begin
(display "created escape proc")
(newline))))
(define (get-string)
(let ((result (call/cc (lambda (c) (set! cont c) #f))))
(if result
result
(begin
(display "escaping... ")
(escape)))))
(define (done-reading result)
(if cont
(let ((tmp cont))
(set! cont #f)
(tmp result))))
(define (bind)
(display (get-string))(newline))
Here's what MIT Scheme does:
1 ]=> (make-escape)
created escape proc
;Unspecified return value
1 ]=> (bind)
escaping... escaped
;Unspecified return value
1 ]=> (done-reading "hi")
hi
;Unspecified return value
1 ]=> (done-reading "there")
;Unspecified return value
1 ]=>
which is exactly what I'd expect. Here's what Guile 1.6.0 does:
guile> (make-escape)
created escape proc
guile> (bind)
escaping... escaped
guile> (done-reading "hi")
(#<procedure #f (c)>)
guile> (done-reading "there")
guile>
guile> (get-string)
escaping... escaped
guile> (done-reading "hi")
"hi"
guile>
Obviously somewhat less violent than before, but apparently no more
correct... Note that calling get-string directly still seems to work.
Should I create an official bug report for this? What is the right
procedure for doing so?
>
> another way to do what I'm trying to do?
>
> probably you can continue your explorations in this vein w/ more
> debugging support: use `trace' and `pk' to determine where things go
> wrong, and/or use a guile version that behaves as you expect.
>
> all other ways essentially devolve into using continuations.
>
Well, at this point I'm depending on 1.6, so that's not really an
option. Plus, I just don't get the feeling that the claims that
guile's non-linear continuations interact correctly with C code are
totally reliable (especially since they seem to have problems even
without C code!), so I'd prefer to avoid using them if possible. Which
really just leaves me with only one choice: re-architect my project so
that the problem goes away. I think that should be OK, now that I know
it's what I need to do.
I imagine someone who's been using Scheme for more than one week would
probably have rather better ideas about this anyway... :)
Thanks for your help, and please let me know what I should do to
submit a bug report!
Take care,
Matt
--
Matt Hellige matt@immute.net
http://matt.immute.net
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
next prev parent reply other threads:[~2002-12-18 18:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-18 17:27 Continuations: possible newbie question Thien-Thi Nguyen
2002-12-18 18:14 ` Matt Hellige [this message]
2002-12-18 20:04 ` Neil Jerram
2002-12-18 23:51 ` Matt Hellige
2002-12-19 0:41 ` Marius Vollmer
2002-12-19 2:42 ` Matt Hellige
-- strict thread matches above, loose matches on Subject: below --
2002-12-18 18:42 Thien-Thi Nguyen
2002-12-18 0:14 Matt Hellige
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=20021218121410.A24945@metro.immute.net \
--to=matt@immute.net \
/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).