From: Nicolas C. <war...@fr...> - 2004-03-20 09:44:41
|
> > - base64 encode/decode > > - abstract high level I/O with support for C basic types ( read_i16 , > > write_f16 ..... ) > > - zlib deflate/inflate written in pure OCaml. > > One of the things I've been nooddling around with is a radicaly new I/O > arhitecture. The basic idea is to make i/o more like java and less like > C. The core idea is that there would be four classes of objects: [...] Hi Brian, What we need is an high-level IO abstraction that will offer a wide API for most of the common usages. The IO module I posted earlier on this list was a beginning of answer to this. It didn't made his way to the CVS because I lacked time, but looks like there was no people against it. In this IO module, I made the following choices regarding polymorphism : (quoting myself) For efficiency reason each input/output have two ways of reading/writing data : for example a channel input can write char by char or directly strings. it's then a (char,string) input. An ouput takes a third parameter which is the value returned by a call to close. (end-of-quote) So we have here : * ('a,'b) input : an input to a file is a (char,string) input * ('a,'b,'c) output : an output to a buffer is a (char,string,string) output since "closing" the buffer returns the total string written into we can provide several conversion "parsers" functions such as * val in_ord : (char,string) input -> (int,int list) input * val in_chr : (int,int list) input -> (char,string) input or "filters" such as : * val in_b64 : (char,string) input -> (char,string) input * val out_zlib : (char,string,'a) output -> (char,string,'a) output Concerning the "Directories", I think its even more high level and should be handled in a different module that will be built on top of IO. Please remember that the "file" concept have no meaning in an abstract IO. Concerning Unicode, adding a filter to handle this looks okay (not by default). For the "polymorphism" of formatters, this is not really possible in the OCaml type system. One choice is to use printf/scanf on an output : that's exactly what's I'm doing in IO module. Regards, Nicolas Cannasse |