From: Nicolas C. <war...@fr...> - 2004-04-09 17:10:23
|
> > I don't like so much the idea of having nread returning a pair. > > Fine, I can see why you might want a simpler interface in a > general-purpose library. I really did it that way because it was > slightly more convenient with the code I'm using myself, but I guess > that's not a very good design principle... ^^; > > > I have been looking a little and it looks ok to modify the behavior > > of IO without actually modifying the interface. We just have to > > replace really_input by input - followed by a String resize if the > > readed number of chars is lower than the requested one. > > The only reason I didn't use Pervasives.input is that it doesn't promise > to return the number of items you requested, even if that many are > available - for all the other inputs, that does seem to be guaranteed. > I'm not sure if it really matters or not. > > > Please tell me if it's ok for you this way, I'll then make the > > changes. > > Yes, the version you describe would work just as well for me. Some quite minor modifications have been made to the following functions : - input_string - input_channel - input_enum - pipe So now when asked about n elements to read when only n' available ( and 0 < n' < n ), nread will return the n' available elements instead of raising No_more_input . IO should now work correctly when used on buffered streams. Regards, Nicolas Cannasse |