[Haskell-cafe] Re: Hugs vs GHC (again) was: Re: Some randomnewbiequestions

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Tue Jan 11 15:18:59 EST 2005

Marcin 'Qrczak' Kowalczyk wrote:

 >"fileRead :: File -> FileOffset -> Integer -> Buffer -> IO ()"
 >This is unimplementable safely if the descriptor is read concurrently
 >by different processes. The current position is shared.

... which is terrible library design, which we should avoid if at all 
possible, which is one of several reasons that I want to get rid of the 
notion of "current position". Hence the above prototype.

fileRead can be implemented in terms of OS primitives, and it's easy 
enough to implement a thread-safe seek/read interface on top of it. The 
reverse isn't true--if we provided seek/read, it would be very hard to 
implement fileRead safely. (Maybe that's what you were saying?)

-- Ben

More information about the Haskell-Cafe mailing list