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

Re: (stream-cons (1) stream-null) => stream

On Fri, 10 Nov 2006, David Van Horn wrote:

David Van Horn wrote:

   (stream-cdr (stream-cons (1) stream-null))

Which should evaluate to a stream ...

I do not think this statement is necessarily correct. I believe it is legitimate for this to give the error it currently does.

In other words, I think it is legitimate to define the stream abstraction
to be

  (stream-cons exp1 exp2) = (delay (cons exp1 exp2))

which is essentially how the current implementation does it, if I remember correctly. Your alternative abstraction would correspond to

  (stream-cons exp1 exp2) = (delay (cons (delay exp1) exp2)),

although if you want to be consistent, you should also delay exp2. This is not illegitimate, but the extra laziness is really orthogonal to
the abstraction.  It can be added by hand when desired, as in

  (stream-cdr (stream-cons (delay (1)) stream-null))

independently of the basic machinery provided to manipulate the stream-part
of the abstraction.