text: 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 return (lambda (val) val)))) (loop)) [ 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))) (loop) is supposed to not grow the stack. Do we want to fix that? This would kick out my loved `current-module' scheme... ]