From: Peter J. <pe...@jo...> - 2004-04-09 12:44:12
|
> Could you explain how really_input cannot be used on stdin ? Maybe I > misunderstood the differences with input, but the documentation doesn't say > anything about really_input not working on stdin. Apologies - I sent that by accident before I was ready, so it wasn't phrased very well. Of course really_input works on stdin, I was thinking of in_channel_length, and IO does wrap that appropriately. However, the specific case that was giving me problems was using IO as a layer for accessing a stream compressed with zlib. The stream might be stdin, so I can't count on knowing how long it is, but for efficiency I want to read it in blocks rather than one byte at a time. In C I'd use fread(), in ocaml normally I'd use Pervasives.input. IO currently provides no equivalent. Sure, it can be done char by char with IO.read, but I'm pretty sure that's going to wind up much less efficient than a hypothetical function which called Pervasives.input, String.sub, or whatever as appropriate. I note that this seems to be inconvenient for you, too, going by the zlib code you just posted. ;) Since I want to be able to use data from stdin, and I want to be able to handle streams larger than Sys.max_string_length, I can't use your version... |