Hello! Use of multiple values breaks tail recursion in VM-compiled code:
(let loop ((x 1000000)) (and (> x 0) (call-with-values (lambda () (values (1+ x) (1- x))) (lambda (next prev) (loop prev))))) This example yields a stack overflow with the VM, whereas tail recursion is correctly handled by the interpreter. Tail recursion for `call-with-values' is mandated by R5RS (info "(r5rs)Proper tail recursion"): Certain built-in procedures are also required to perform tail calls. The first argument passed to `apply' and to `call-with-current-continuation', and the second argument passed to `call-with-values', must be called via a tail call. Similarly, `eval' must evaluate its argument as if it were in tail position within the `eval' procedure. I'll look into it and report back if no one beats me. ;-) Thanks, Ludo'.