unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Strange behavior with delayed objects
@ 2010-05-04  6:32 user8472
  2010-05-04 15:21 ` Linas Vepstas
  2010-05-14 21:53 ` user8472
  0 siblings, 2 replies; 12+ messages in thread
From: user8472 @ 2010-05-04  6:32 UTC (permalink / raw)
  To: Guile-user


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))
    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: http://old.nabble.com/Strange-behavior-with-delayed-objects-tp28443452p28443452.html
Sent from the Gnu - Guile - User mailing list archive at Nabble.com.





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-05-21 10:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-04  6:32 Strange behavior with delayed objects user8472
2010-05-04 15:21 ` Linas Vepstas
2010-05-04 16:59   ` user8472
2010-05-05 14:53     ` Linas Vepstas
2010-05-07  8:09       ` user8472
2010-05-10 16:26         ` Linas Vepstas
2010-05-10 16:28           ` Linas Vepstas
2010-05-10 21:36           ` user8472
2010-05-10 22:08             ` Linas Vepstas
2010-05-21 10:52   ` Andy Wingo
2010-05-14 21:53 ` user8472
2010-05-21 10:59   ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).