Re: Much simpler leak-free implementation possible? Andre van Tonder (18 Aug 2003 20:10 UTC)
Re: Much simpler leak-free implementation possible? Phil Bewig (19 Aug 2003 07:33 UTC)

Re: Much simpler leak-free implementation possible? Andre van Tonder 18 Aug 2003 20:10 UTC

Hello Phil,

Thank you very much for your insights.

> I encourage you to extend your proof-of-concept to a full reference
> implementation.

Thank you for the invitation.  I'll see what I can do, if time allows.

> Second, you will need to decide on and implement some abstraction
> that hides the underlying cps mechanism.

Yes.  I've been thinking about that.  I have some untested ideas, but
as you noted, I'm not sure they fit well with the traditional stream API
(e.g. having to use car/cdr instead of stream-car, stream-cdr).  The
result might not be suitable for this SRFI.

> I belive your characterization of your stream-unfold as "trivial" and
> "vastly simpler" than the one in the srfi reference implementation
> is unfair, because you solve a considerably simpler problem.

Conceded.

> I can tell you that times3 runs to completion and correctly
> evaluates (times3 1000000) on my Windows 98 machine, using
> both MzScheme and Petite Chez Scheme, without thrashing
> the hard disk looking for memory, ...

This is also true on my machine.  However, when I try
(times3 100000000), I do run out of memory (it is easy to see in the
performance tab of the Windows task manager that the memory consumed
increases up to >400MB, at which point it starts thrashing).  Perhaps I'm
doing something wrong.  Are you using the definition?

  (define from0
     (let loop ((x 0))
       (stream-delay
         (stream-cons x (loop (+ x 1))))))

The CPS solution does not have the same problem on my machine.  It just
seems to run forever with pretty much flat space consumption.

Best regards
Andre