[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Continuations and scheme level wrappers
From: |
Mikael Djurfeldt |
Subject: |
Re: Continuations and scheme level wrappers |
Date: |
30 Nov 2000 21:49:24 +0100 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 |
Gary Houston <address@hidden> writes:
> > From: Mikael Djurfeldt <address@hidden>
> > Date: Thu, 30 Nov 2000 18:01:46 +0100
> >
> > I saw your recent change maing continuations applicable smobs.
> >
> > Question: Will the new continuations be properly tail-recursive?
> >
> > They need to be...
> >
> > They should, for example, handle a situation where a recursion
> > repeatedly creates a continuation and calls it tail-recursively
> > without leaving anything on the stack.
>
> Hi Mikael,
>
> Do you mean something like this?
>
> (define cont #f)
>
> (define (a)
> (call-with-current-continuation (lambda (c)
> (set! cont c)))
> (b))
>
> (define (b)
> (if (< (random 10) 5)
> (cont #f)
> (a)))
Yes,
(define (a)
(call-with-current-continuation (lambda (c) (c #f)))
(a))
should not grow the process, but nor should
(define (b)
(call-with-current-continuation (lambda (c) (b))))
> Judging by process size, this seems to be tail recursive when using
> the normal evaluator
Yes, I now had a quick look at your changes, and they look good to me.
I reacted to the "avoid Scheme wrapper" comment in the ChangeLog and
thought you meant the wrapper for call/cc in r4rs.scm.
Actually, now you've partially factored out continuations from the
evaluator so that Guile becomes slightly more modular. That is very
good.
> but not when using the debugging evaluator.
Hmm... this is a bug which should be fixed.
Best regards,
Mikael