[iterate-devel] in-stream closes stream at the end: bad idea?

Chris Dean ctdean at sokitomi.com
Wed Oct 22 22:18:23 UTC 2008


"daniel radetsky" <dradetsky at gmail.com> writes:
>> My idea is of something like this:
>> (iter (for x in-stream (open-file .....) close-stream t))

That's not a bad idea, but it would be nice if close-stream defaulted to
true.  

> Why should it close the stream, especially when streams are generally
> created inside UNWIND-PROTECT-based macros?

That is not the case I most commonly use.  Typical usage is:

        (iter (for x :in-stream (make-my-stream))
              ...)

This is shorter and more convenient than the equivalent (assuming the
CLOSE-STREAM option):

        (with-open-stream (s (make-my-stream))
         (iter (for x :in-stream s :close-stream nil)
               ...)

And you don't even really need the CLOSE-STREAM option in this case,
since all we would do is close the stream twice.

(Of course, Both of these have a CLOSE inside an UNWIND-PROTECT block.)

Cheers,
Chris Dean





More information about the iterate-devel mailing list