From: John G. <jgo...@co...> - 2004-04-26 00:55:56
|
On Sun, Apr 25, 2004 at 10:41:26PM +0200, Nicolas Cannasse wrote: > Here's some OO wrappers proposal for IO module. > > As Yamagata Yoriyuki suggested, theses can be useful in order to provide > ExtLib IO compatibility without the need to add a dependency to IO module I've just started looking at this project, but I am confused about what IO module you're talking about -- I don't see one at http://ocaml-lib.sourceforge.net/doc/. In any case, I have thought about some sort of generic wrapper for I/O as well. In OCaml, there are already two different I/O capabilities in the standard distribution -- the channels in Pervasives, and the Unix module's capabilities. It would be useful to, IMHO, define a standardized interface that can be implemented for both these and other types. For instance, one might have: ReadableFile Methods: read(), readline(), readlines(), etc. WritableFile Methods: write(), flush(), truncate(), etc. SeekableFile Methods: seek(), tell(), etc. Any given implementation could inherit and implement one or both of ReadableFile and optionally SeekableFile. There would be other benefits to this as well. For instance, one could implement a virtual file object using Buffers. This would be similar in concept to Python's StringIO, which lets you pass a file-like object to any function expecting to do I/O; that I/O is emulated, and the contents of the string can be accessed later. -- John |