[Top][All Lists]

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

Re: guile-vm 0.4

From: Marius Vollmer
Subject: Re: guile-vm 0.4
Date: 11 Apr 2001 01:42:47 +0200
User-agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7

Keisuke Nishida <address@hidden> writes:

>   (let loop ()
>     (catch #t
>       (lambda () (loop))
>       (lambda val val)))
> Here, `catch' is a primitive procedure, and `loop' is a vm program.
> Although `loop' is supposed be tail-called, it actually calls a new
> vm and consumes the vm stack.  I'm not going to fix this right now
> because it's not a big problem for the moment.
> (BTW, Guile does not support it, either:
> guile> (let loop () (catch #t (lambda () (loop)) (lambda val val)))
> $1 = (stack-overflow #f "Stack overflow" #f #f)
> Is this supposed?)

No.  The call to `loop' is in a tail position, but the surrounding
`lambda' is not invoked in such a position.  Calling `loop' from the
inside of the `catch' does not terminate it.  Even tho you are
looping, you keep piling the catch activations.  You would need to use
an explicit continuation to jump out of the catch, like

    (let loop ()
      (call/cc (lambda (return)
                          (catch #t
                            (lambda (val) val))))

[ I just reread the "Proper Tail-Recursive" section of R5RS, and I
  noticed that `eval' is required to be proper.  That is,

    (define (loop)
      (eval '(loop) (current-module)))

  is supposed to not grow the stack.  Do we want to fix that?  This
  would kick out my loved `current-module' scheme...

reply via email to

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