[Top][All Lists]

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

Strange behavior with delayed objects

From: user8472
Subject: Strange behavior with delayed objects
Date: Mon, 3 May 2010 23:32:29 -0700 (PDT)

I am currently working through SICP using Guile. I have found some strange
behavior when doing the exercises in chapter 3.5. I am running Guile 1.4
installed via Fink on Mac OS X 10.6, all latest patches installed. The
problem also exists in Guile 1.8.6.

This code works fine (and computes e):
  (define y (integral (delay dy) 1 0.001))
  (define dy (stream-map (lambda (x) x) y))
  (stream-ref y 1000)

The following code *should* be identical:
  (define (solve f y0 dt)
    (define y (integral (delay dy) y0 dt))
    (define dy (stream-map f y))
  (solve (lambda (x) x) 1 0.001)

But it yields the error message:
standard input:7:14: While evaluating arguments to stream-map in expression
(stream-map f y):
standard input:7:14: Unbound variable: y
ABORT: (unbound-variable)

So when embedded in a procedure definition, the (define y ...) does not
work, whereas outside the procedure it works fine.

What am I doing wrong here? I can post the auxiliary code (i.e., the
definitions of integral, stream-map etc.) if necessary, too.
View this message in context:
Sent from the Gnu - Guile - User mailing list archive at

reply via email to

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