[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] srfi-40 space leak?
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] srfi-40 space leak? |
Date: |
Tue, 11 Apr 2006 14:44:47 +0200 |
User-agent: |
Mutt/1.4.2.1i |
On Tue, Apr 11, 2006 at 01:46:05PM +0200, felix winkelmann wrote:
> On 4/10/06, Dan <address@hidden> wrote:
> > Hi all,
> >
> > After reading the SRFI-40 (stream library) egg
> > documentation at
> >
> > http://www.call-with-current-continuation.org/eggs/srfi-40.html
> >
> > I thought that the implementation includes the srfi-45
> > fixes to avoid space leaks. However, the test program
> > below seems to take up an ever-increasing amount of
> > memory. What gives?
> >
>
> Hm. I don't use streams much, but since you are referencing
> the 5-gazillionth element, you probably have to build the
> list up to that element, or not?
He is looping through the elements with a tail-recursive function.
This should not pose any problems, since only the car of the list needs
to be forced, after which it is discarded and recursion takes place on
the cdr.
I don't completely understand everything in SRFI-45, but it looks like
the implementation of stream-unfoldn (used by stream-filter) should use
lazy instead of delay?
If I understand correctly, delay and force are not "fixed" by SRFI-45, but
the algorithm of converting a program to a lazy version of the program is
"fixed" by requiring lazy instead of delay.
HTH,
Peter
--
http://www.student.ru.nl/peter.bex
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
pgpUy8E4JOjiN.pgp
Description: PGP signature