Stream-filter and space leaks
Phil Bewig
(20 Feb 2003 14:08 UTC)
|
Re: Stream-filter and space leaks
Richard Kelsey
(20 Feb 2003 18:41 UTC)
|
Re: Stream-filter and space leaks
Phil Bewig
(21 Feb 2003 09:57 UTC)
|
Re: Stream-filter and space leaks
Richard Kelsey
(21 Feb 2003 23:18 UTC)
|
Re: Stream-filter and space leaks
sperber@xxxxxx
(21 Feb 2003 10:04 UTC)
|
Re: Stream-filter and space leaks
Richard Kelsey
(21 Feb 2003 15:06 UTC)
|
Re: Stream-filter and space leaks
Matthias Neubauer
(25 Feb 2003 16:01 UTC)
|
Re: Stream-filter and space leaks
Richard Kelsey
(25 Feb 2003 18:25 UTC)
|
Re: Stream-filter and space leaks
Matthias Neubauer
(25 Feb 2003 21:32 UTC)
|
Re: Stream-filter and space leaks
Richard Kelsey
(25 Feb 2003 22:11 UTC)
|
Re: Stream-filter and space leaks
sperber@xxxxxx
(26 Feb 2003 08:18 UTC)
|
Re: Stream-filter and space leaks
Matthias Neubauer
(26 Feb 2003 13:31 UTC)
|
Re: Stream-filter and space leaks
sperber@xxxxxx
(11 Mar 2003 14:58 UTC)
|
Re: Stream-filter and space leaks Matthias Neubauer (19 Mar 2003 15:27 UTC)
|
Re: Stream-filter and space leaks
felix
(22 Mar 2003 09:49 UTC)
|
Re: Stream-filter and space leaks
felix
(22 Mar 2003 09:56 UTC)
|
xxxxxx@informatik.uni-tuebingen.de (Michael Sperber [Mr. Preprocessor]) writes: > >>>>> "Matze" == Matthias Neubauer <xxxxxx@informatik.uni-freiburg.de> writes: > > Matze> The real problem is see is the following: as soon as I apply some kind > Matze> of abstraction over STREAM-FILTER---which is something every Schemer > Matze> wants to do of course---, hell breaks loose again. E.g., if I type > > Matze> (define (filter-zero stream) > Matze> (stream-filter (lambda (x) (zero? x)) > Matze> stream)) > > Matze> (stream-car (filter-zero (stream-from 1))) > > Matze> in scsh, I will again see a space leak. > > Matze> Considering all the major Scheme implementations, how common is it to > Matze> use a flat closure representation for procedures? > > This won't be solved by flat closures---the call to FILTER-ZERO is a > non-tail call, and it'd be necessary to mark dead variables in > continuation frames to make this not leak. Your're right of course. There is not only the possibility that we have to deal with closures that retain too many references but we can also have continuation frames with this exact same deficiency. Just for kicks, I just tested some Scheme implementations I had access to to see how they'd behave in this respect. I tried scsh 0.6.4 (Beta 1) | Scheme 48 0.57 | petite scheme 6.0a | MzScheme3m 203.6 | Larceny v1.0a1 Always in this very order, always without any special runtime options. "ok" means that an example leads to a true endless loop, "leaks" means that the system aborts after a while. ;; ex 1: simple loop (let loop ((p (cons 1 2))) (let ((p2 (cons 1 2))) (set-cdr! p p2) (loop p2))) ;; ok | ok | ok | ok | ok ;; ex 2: almost the same but not quite ... (let ((p (cons 1 2))) (let loop ((p p)) (let ((p2 (cons 1 2))) (set-cdr! p p2) (loop p2)))) ;; leaks | ok | ok | ok | ok ;; ex 3: closure check (let ((p (cons 1 2))) (let ((fun (lambda (x) x))) (let loop ((p p)) (let ((p2 (cons 1 2))) (set-cdr! p p2) (fun 42) (loop p2))))) ;; leaks | ok | ok | ok | ok ;; ex 4: continuation frame check (let ((p1 (cons 1 2))) (let loop ((p p1)) (let ((p2 (cons 1 2))) (set-cdr! p p2) (loop p2))) '42) ;; leaks | leaks | leaks | leaks | ok Maybe this SRFI should require a Scheme implementation with a certain safe-for-space property. Or maybe every implementation of this SRFI should at least state somehow how it behaves under implementations with different safe-for-space properties. Otherwise users will trip into the exact same problems I did when filtering streams with scsh ... Cheers 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