[racket] stream-cons from racket/stream isn't lazy

From: Eugene Toder (eltoder at gmail.com)
Date: Sat Mar 5 17:18:31 EST 2011

Matthias,

Is there a reason to use streams in lazy racket? Won't lists give me
the same behaviour?

> (define (foo) (display "called\n") '())
> (cons 1 (foo))
'(1 . #<promise:temp9>)

I though that the whole point of streams was to provide lazy lists in
a strict language.

Eugene

On Sat, Mar 5, 2011 at 5:11 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> Consider using Lazy Racket. -- Matthias
>
>
>
> On Mar 5, 2011, at 3:36 PM, Eugene Toder wrote:
>
>> Hello,
>>
>> stream-cons from racket's standard racket/stream.rkt is implemented as
>> a macro -stream-cons wrapped into a case-lambda.
>> This wrapping makes it strict in both arguments, contrary to the
>> traditional behaviour from SICP, srfi-40, srfi-41 etc.
>> For example:
>>
>>> (define (foo) (display "called\n") empty-stream)
>>> (stream-cons 1 (foo))
>> called
>> #<sequence>
>>> (require srfi/41)
>>> (stream-cons 1 (foo))
>> #<stream>
>>
>> Is this intentional? Is there a way to get traditional lazy behaviour
>> other than by implementing it with make-do-sequence or generator?
>>
>> Eugene
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/users
>
>



Posted on the users mailing list.