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

daniel radetsky dradetsky at gmail.com
Tue Oct 21 21:29:48 UTC 2008


Iterators:

Was working with iterate, and noticed this issue. I did a
quick-n-dirty fix to get rid of it (copy and paste to a new in-ostream
driver). But I thought: Is there actually a good reason to close the
stream at the end of the loop? Or, is there a correct way to make
in-stream not close the stream that I should have been using?

If not, and if there is still development going on for iterate, I can
fix it up more nicely and submit a patch. My thoughts:

- in-stream should, by default, not close the stream. Unlike in-file,
we should expect that the stream was created by some process that will
handle closing the stream at the end, such as with-open-file.

- If the user wants to close the stream at the end, he should do
something like (finally (close stream)). More complicated abstractions
here aren't really helpful.

I had also been thinking that in-stream/in-file could be modified to
make it easier to pass them user-defined reading functions, but that's
another post.

Daniel




More information about the iterate-devel mailing list