guile-devel
[Top][All Lists]
Advanced

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

Re: SRFI 41, revisited


From: Chris K. Jester-Young
Subject: Re: SRFI 41, revisited
Date: Tue, 11 Sep 2012 02:56:51 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Sep 11, 2012 at 01:58:26PM +0800, Daniel Hartwig wrote:
> This is not compatible with the (ice-9 streams) module is it?  At
> least, it does not appear to be by quickly scanning the source.

Nope, the two are not related at all. As you've correctly identified,
(ice-9 streams) uses a generator, whereas SRFI 41 uses stream-cons so
that you can build streams recursively from other streams (but in a way
that doesn't bust your stack).

The magic ingredient in all of this is SRFI 45's lazy, which is not
provided by standard Scheme promises.

In so saying, SRFI 41 does provide a generator-style stream builder too,
in the form of stream-unfolds. So it shouldn't be hard to port code from
using (ice-9 streams) to SRFI 41. The other direction isn't quite so
simple. ;-)

> At the time I investigated the two alternate implementations (ice-9's
> make-stream is constructed using a generator) and found that depending
> on the use case either approach could be more efficient in terms of
> coding and run-time performance.  So at least having the two options
> is great.

Yes, I think both libraries have a place; although SRFI 41 can do
everything (ice-9 streams) can do, it's also somewhat more complicated,
and sometimes all you need is something quick and easy.

> I wonder if there is an underlying base which is common to both
> methods…  Such a base is great if ice-9 streams were extended with the
> useful procedures as well (stream-filter, stream-ref, etc.).

I don't think there is a common base, since a lot of SRFI 41's utility
functions do make use of stream-cons. But you can reimplement them for
(ice-9 streams) in order to provide the same API. Then code can more
easily switch between the two implementations without requiring too much
source changes.

> Anyway, looks quite good and I'll play more with this module during the week.

Sounds good. Thanks!

Cheers,
Chris.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]