Stefan O'Rear wrote:
On Fri, Jul 13, 2007 at 07:59:22PM +0100, Andrew Coppin wrote:
Care to elaborate on "bad things"? (I.e., will this just crash the program with an error, or will it do something more serious?) I must admit, I thought closing such a file was simply no-op.

If you close the file, the stream will suddenly end.  I believe silent
data corruption is worse than a crash :)

Agreed...! o_O

I can't remember why exactly, but somewhere or other I wrote some code that does this. (Basically I want to shut the file without reading all of it, so I can reopen it and start reading from the beginning again.) Is there a sane way to do this? Or am I going to have to start playing with explicit reads and writes? (Obviously I could just hang on to *all* of the input stream returned from getContents - but that could be quite large. The current way gives me low memory usage...)

Did you actually try it?

I am not 100% sure about this. I wrote code that had an execution path that does this, but I don't know if I ever actually *excercised* it...

(The idea was to read, say, 10% of the file, and then close it and start reading from the beginning again.)

How about redundantly closing the file after you've already read all of it anyway? Is that dangerous?

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to