OK, I have found a solution. The point is that in section 4.2.2 of R5RS it is
explicitly stated that mutually recursive defines must not refer to those
variables. The solution is thus to wrap the defines in (lambda () ...)s.

<code>
(define (solve f y0 dt)
  (define (y) (integral (delay (dy)) y0 dt))
  (define (dy) (stream-map f (y)))
  (y))

(debug-set! stack 2000000)
(stream-ref (solve (lambda (x) x) 1 0.001) 1000)
</code>

will produce the correct answer. The downside is that the function calls
will be wrapped recursively which necessitates increasing the stack size.
Plus, it's much slower this way. But it works.
-- 
View this message in context: 
http://old.nabble.com/Strange-behavior-with-delayed-objects-tp28443452p28564620.html
Sent from the Gnu - Guile - User mailing list archive at Nabble.com.


Reply via email to