scsh-users
[Top] [All Lists]

Re: cons-streams and SCSH

To: scsh@martigny.ai.mit.edu
Subject: Re: cons-streams and SCSH
From: Sean Doran <smd@chops.icp.net>
Date: 21 Aug 1996 19:57:47 -0400
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.

<Prev in Thread] Current Thread [Next in Thread>