readFile close behaviour
Jens Petersen
petersen at redhat.com
Fri Oct 5 09:07:27 EDT 2001
"Marcin 'Qrczak' Kowalczyk" <qrczak at knm.org.pl> writes:
> 05 Oct 2001 17:51:45 +0900, Jens Petersen <petersen at redhat.com> pisze:
>
>> IMHO hugs is doing the right thing here. Shouldn't ghc also
>> close semiclosed handles when all references to them have
>> been dropped?
>
> I guess it would close, but garbage collection didn't notice yet that
> all references have been dropped.
Perhaps. Is it meaningful to ask, what is the default average time
between GCs?
> BTW, it's not necessarily semiclosed: you are throwing away the
> contents and it will be open or semiclosed dependent on how much is
> read by readFile before returning (perhaps nothing and it's thus open).
True.
> If it was semiclosed, the physical handle could be closed immediately.
I think my statement was too weak. It shouldn't matter whether the
handle is open or semi-closed: if there are no references left to it
it should be closed. In fact in the example I gave one could even
argue that the file need never be opened?
Anyway if hugs can do right, I think the compilers should be able to
too.
Jens
More information about the Glasgow-haskell-bugs
mailing list