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

Re: Stream-filter and space leaks

This page is part of the web mail archives of SRFI 40 from before July 7th, 2015. The new archives for SRFI 40 contain all messages, not just those from before July 7th, 2015.



sperber@xxxxxxxxxxxxxxxxxxxxxxxxxxx (Michael Sperber [Mr.  Preprocessor]) writes:

> >>>>> "Matze" == Matthias Neubauer <neubauer@xxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
> 
> Matze> Richard Kelsey <kelsey@xxxxxxx> writes:
> 
> >> Our different experiences may be based on differences between the 0.57 and
> >> the Scheme 48 version underlying Scsh 0.6.3.  I don't know which version
> >> that is.
> 
> Matze> Well, that's what I already feared. To me, this means either that my
> Matze> scsh is somehow "buggy" or that we still don't have a portable,
> Matze> non-leaking implementation of STREAM-FILTER.
> 
> There's no way to do that in general.  However, if you take the code
> Phil posted last and lambda-lift the internal definitions out, you'll
> get something that works pretty much everywhere (certainly in Scheme
> 48 and scsh), I conjecture.

Yes, this does the trick. After lambda-lifting STREAM-FILTER,

   (stream-car (stream-filter (lambda (x) (zero? x)) (stream-from 1)))

also loops in my scsh.

The real problem is see is the following: as soon as I apply some kind
of abstraction over STREAM-FILTER---which is something every Schemer
wants to do of course---, hell breaks loose again. E.g., if I type 

   (define (filter-zero stream)
     (stream-filter (lambda (x) (zero? x)) 
                    stream))
   
   (stream-car (filter-zero (stream-from 1)))

in scsh, I will again see a space leak.

Considering all the major Scheme implementations, how common is it to
use a flat closure representation for procedures?

-Matthias

-- 
Matthias Neubauer                                       |
Universität Freiburg, Institut für Informatik           | tel +49 761 203 8060
Georges-Köhler-Allee 79, 79110 Freiburg i. Br., Germany | fax +49 761 203 8052