[racket-dev] racket/stream

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Mar 18 21:08:15 EDT 2011

At Thu, 17 Mar 2011 16:13:26 -0400, Eli Barzilay wrote:
> Yesterday, Matthew Flatt wrote:
> > I see your point about "generator", and so I agree that we should
> > use a different term. I'm not too happy with the term "producer",
> > but I don't yet have a better suggestion.

For now, I've left the generator and producer support as it was --- no
particular emphasis or support for stateful sequences, and so no
particular need for terminology.

> > I don't think that 0-arity procedures should be the only
> > implementation of producers. [...]
> I like the lack of such identification -- it makes it easy to just use
> something like (lambda () 1) as the producer equivalent of an infinite
> stream of 1s.

I never meant to suggest that a thunk couldn't be a producer --- only
that producers might have representations other than thunks. Again,
it's moot for now.

> > I'm not convinced that `racket/sequence' is useless. Here's a list of
> > the current functions (with the current names):

I threw out `sequence-cons', `sequence-first', and `sequence-rest', and
I kept the rest. The various functions are all unnecessary on some
level, just like `map', `for-each', and `compose' are unnecessary on
some level But the function forms and/or alternate names look handy for
some contexts.

The new `racket/stream' library provides stream versions of the
functions, plus `stream-cons' (based on SRFI-41), `stream-empty?',
`stream-first', and `stream-rest'.

Meanwhile, `in-range' now produces a stream, the `for' variants support
streams in a slightly more direct way, etc.

Posted on the dev mailing list.