[racket-dev] racket/stream

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Mar 17 16:10:36 EDT 2011

At Thu, 17 Mar 2011 15:53:51 -0400, Matthias Felleisen wrote:
> That's the heart of the question, its distillation to a one-liner. 
> The real question how a list can __be__ a stream and how a LR stream can 
> __be__ a stream. 

It's in the same way that a list can be a sequence and a vector can be
a sequence.

The intent is that "stream" is an API that can be implemented for
multiple representations. The representations of streams created by
`stream-cons' and `cons' are different, but the `stream-empty?',
`stream-first', and `stream-rest' operations can support both of those
representations (and more).

This might be a generalization of "stream" as it is sometimes used (I'm
not sure), and we have already discarded an attempt to generalize
"generator". The difference is that generators support some operations
(such as arguments to the generator) that are not be supported by
stateful sequences in general. In contrast, functional sequences in
general support any operation that `stream-cons'-streams support. It's
just a question of how the stream is represented.

Posted on the dev mailing list.