From: skaller <sk...@us...> - 2004-08-31 01:13:54
|
On Tue, 2004-08-31 at 05:26, Bardur Arantsson wrote: > It seems there is no function to read exactly n characters > into a string (ie. IO.nread just without automatically > shortening the string if EOF is hit while reading). Since > at least one person needs it (me :)) I thought I would add > this: > > let really_nread i n = > if n < 0 then raise (Invalid_argument "IO.really_nread"); > if n = 0 then Seeing the exception being raised here suggests to me Ocaml needs a better mechanism for errors. The exception being raised conforms to the "Same way as Ocaml std lib" policy. It exhibits these problems: (1) It doesn't say which argument (2) It doesn't say what the problem was (3) There's no reference to the file/line position of the raise >This will cause an infinite loop on non-blocking IO (r = 0). >You might want to raise Sys_blocked_io in this case. Weird. You raise Sys_blocked_io when in fact the problem is that it *isn't* blocked?? -- John Skaller, mailto:sk...@us... voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net |