Oh, along the same topic, I found that if I replace
the non-destructive stream->file in the previous message
with this function, which side-effects the stream:
(define (stream->file f s)
(let ((p (open-output-file f)))
(letrec ((write-stream
(lambda (stream)
(if (not (stream-null? stream))
(let ((tail (stream-cdr stream)))
(write-char (stream-car stream) p)
(set-cdr! stream '())
(write-stream tail))))))
(write-stream s)
(close-output-port p))))
then I can copy the Really Big File from the previous
example.
However, I'm still thinking that the previous
elements in the stream shouldn't be pointed-to
by anything, and therefore should be reclaimed
as garbage. Is this wrong?
Sean.
|