[plt-scheme] SRFI 41

From: michael rice (nowgate at yahoo.com)
Date: Wed Oct 8 15:07:54 EDT 2008

Thanks. That clears it up somewhat. I sent a copy of my message to the SRFI 41 mail site. Is there anything else I should do, such as forward your comments to them?

Michael

--- On Wed, 10/8/08, Jens Axel Soegaard <jensaxel at soegaard.net> wrote:
From: Jens Axel Soegaard <jensaxel at soegaard.net>
Subject: Re: [plt-scheme] SRFI 41
To: nowgate at yahoo.com
Cc: plt-scheme at list.cs.brown.edu
Date: Wednesday, October 8, 2008, 2:42 PM

michael rice skrev:
> There's a stream-member function given in SRFI 41 that doesn't
seem to 
> work as expected.
>
> =================
>
> (require srfi/41)
>
> (define s1 (stream-cons 'a (stream-cons 'b stream-null)))
>
> (define-stream (stream-member eql? obj strm)
>   (stream-let loop ((strm strm))
>     (cond ((stream-null? strm) #f)
>           ((eql? obj (stream-car strm)) strm)
>           (else (loop (stream-cdr strm))))))
>
> ===================
>
> Welcome to DrScheme, version 4.1 [3m].
> Language: Swindle; memory limit: 128 megabytes.
> > (stream-member equal? 'c s1)
> #<stream>
> >
>
> ===================
>
> Shouldn't the answer be #f?
>
> Michael
>
>

The documentation for srfi 41 says:

(stream-let tag ((var expr) ...) body)

... stream-let evaluates the expressions in its body in an environment 
containing
the newly-bound variables, returning the value of the last expression 
evaluated,
which must yield a stream.

Since #f is not a stream, the behaviour is undefined.

Note that evaluating (stream-car (stream-member equal? 'c s1)) gives #f.

But... The example rises a few questions:

  Is PLT using the reference implementation of srfi 41?

  If not, it would be a worth chaning the behaviour of stream-let to
  match the reference implementation.

  Was it intentional that this behaviour is undefined?

   If it is unintentional, maybe an error message would be better
   than matching the behaviour of the reference implementation?
 


-- 
Jens Axel Søgaard




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20081008/bf3b047a/attachment.html>

Posted on the users mailing list.