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

Re: Should the car be a stream?

This page is part of the web mail archives of SRFI 41 from before July 7th, 2015. The new archives for SRFI 41 contain all messages, not just those from before July 7th, 2015.



At one point in the development of the SRFI the stream-car wasn't delayed.  But that doesn't work, because Scheme is eager, not lazy, so evaluation of the stream-car has to be delayed.  See the typing discussion in the 'Implementation' section for more discussion of this point.

On Nov 14, 2007 5:47 PM, AndrevanTonder <andre@xxxxxxxxxxxxx> wrote:
The following seems wrongly typed to me:

(define-syntax stream-cons
    (syntax-rules ()
      ((stream-cons obj strm)
        (stream-delay (make-stream-pare
                          (stream-delay obj)   ;???
                          (stream-lazy strm))))))

Specifically, I don't think the car of a stream should be a stream.
Instead, shouldn't it be something like

(define-syntax stream-cons
    (syntax-rules ()
      ((stream-cons obj strm)
        (stream-delay (make-stream-pare
                          (delay obj)
                          (stream-lazy strm))))))

But even I am wondering about the rationale for making the stream elements
themselves promises.  It may be useful to leave the types of the elements
(including whether they are promises or ordinary values) orthogonal to the
backbone of the stream itself.

I suspect that if the elements were not themselves delayed by default, you
would see a huge difference in performance.

Andre