chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Bug in implementation for srfi-40?


From: Alejandro Forero Cuervo
Subject: [Chicken-users] Bug in implementation for srfi-40?
Date: Mon, 31 May 2004 23:17:12 -0500
User-agent: Mutt/1.5.5.1+cvs20040105i

Hi.

In Chicken 1.51 I run the following code:

;;; start

(require-extension srfi-40)

(define (stream-echo n)
  (stream-delay
    (begin (format #t "Evaluate: ~A~%" n)
           (stream-cons n (stream-echo (+ n 1))))))

(let ((s (stream-echo 0)))
  (stream-null? (stream-delay s))
  (stream-null? s))

;;; end

This prints the "Evaluate: 0" line *two* times.

Shouldn't the first call to stream-null? cache the result both in
the  stream created  with the  explicit (second)  stream-delay as
well as in the stream s?  And shouldn't the caching of the result
in the stream s be used  in the second call to stream-null?, thus
avoiding having to re-evaluate the body defining the stream?

The following analogous code does print "Evaluate: 0" only once:

;;; start

(define (stream-echo n)
  (delay
    (begin (format #t "Evaluate: ~A~%" n)
           (cons n (stream-echo (+ n 1))))))

(let ((s (stream-echo 0)))
  (null? (force (delay (force s))))
  (null? (force s)))

;;; end

Is  this  a bug  in  the  implementation  of  SRFI-40 or  just  a
misunderstanding on my part?

Thank you!

Alejo.
http://bachue.com/alejo

---=(  Comunidad de Usuarios de Software Libre en Colombia  )=---               
                                               
---=(  http://bachue.com/colibri )=--=( address@hidden  )=---                   
                                           

Attachment: signature.asc
Description: Digital signature


reply via email to

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