Re: [Chicken-users] srfi-40 space leak?
> 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. Thanks Peter -- that's what I meant. The SRFI-40 egg describes itself as space-safe (by virtue of incorporating srfi-45). > 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. Actually, I think force and delay are both "fixed" (as in "improved") in SRFI-45. The reference implementation redefines force and delay and adds "lazy" and "eager". True, the "new" force and delay are backwards-compatible (in the absence of lazy/eager). The algorithm for converting to a lazy algorithm is described in the section "Correct Usage" of SRFI-45. -- Dan __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] srfi-40 space leak?
On Tue, Apr 11, 2006 at 01:46:05PM +0200, felix winkelmann wrote: > On 4/10/06, Dan <[EMAIL PROTECTED]> 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 pgpwFB9tXahwJ.pgp Description: PGP signature ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] srfi-40 space leak?
On 4/10/06, Dan <[EMAIL PROTECTED]> 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? cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] srfi-40 space leak?
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? --- ;; Compile with csc -O3 -R srfi-40 test.scm ;; You may need to install srfi-40: ;; chicken-setup srfi-40 (define stream-ref (lambda (s n) (let loop ((s s) (i 0)) (if (= i n) (stream-car s) (loop (stream-cdr s) (+ i 1)) (define integers-from (lambda (n) (stream-cons n (integers-from (+ n 1) (define integers (integers-from 0)) ; (set-gc-report! #t) (display (stream-ref (stream-filter even? integers) 500)) (newline) -- Dan __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users