guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Continuations: possible newbie question


From: Matt Hellige
Subject: Re: Continuations: possible newbie question
Date: Wed, 18 Dec 2002 12:14:10 -0600
User-agent: Mutt/1.2.5i

[Thien-Thi Nguyen <address@hidden>]
> 
>    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                  address@hidden
http://matt.immute.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]