From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA22464; Wed, 28 Apr 2004 01:32:35 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA22443 for ; Wed, 28 Apr 2004 01:32:33 +0200 (MET DST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.184]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3RNWWjq016294 for ; Wed, 28 Apr 2004 01:32:33 +0200 Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BIayL-0006Sd-00; Wed, 28 Apr 2004 00:22:37 +0200 Received: from [80.129.104.25] (helo=gate.gerd-stolpmann.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BIayJ-0000Dt-00; Wed, 28 Apr 2004 00:22:36 +0200 Received: from ice.gerd-stolpmann.de (ice.gerd-stolpmann.de [192.168.0.13]) by gate.gerd-stolpmann.de (Postfix) with ESMTP id 8F2E657C7; Wed, 28 Apr 2004 00:22:35 +0200 (CEST) Received: by ice.gerd-stolpmann.de (Postfix, from userid 1000) id 182D7B032; Wed, 28 Apr 2004 00:22:33 +0200 (CEST) Subject: Re: [Caml-list] Re: Common IO structure From: Gerd Stolpmann To: Nicolas Cannasse Cc: Yamagata Yoriyuki , caml-list@inria.fr In-Reply-To: <007a01c42c8b$00941ec0$19b0e152@warp> References: <00cb01c42afd$7fc1b430$19b0e152@warp> <20040426.221606.71081508.yoriyuki@mbg.ocn.ne.jp> <015701c42b9a$00065730$ef01a8c0@warp> <20040427.002643.78700697.yoriyuki@mbg.ocn.ne.jp> <016401c42bc4$b6438840$19b0e152@warp> <1083013017.8842.327.camel@ice.gerd-stolpmann.de> <007a01c42c8b$00941ec0$19b0e152@warp> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1083104549.23577.91.camel@ice.gerd-stolpmann.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 28 Apr 2004 00:22:33 +0200 X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:a6865a839c0178d9aa0ce41878507ea2 X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 gerd:01 stolpmann:01 2004:99 cannasse:01 ocamlnet:01 sourceforge:01 netchannels:01 flowing:99 ocamlnet:01 yamagata:01 yoriyuki:01 char:01 buffered:01 ocamlnet's:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Die, 2004-04-27 at 21:08, Nicolas Cannasse wrote: > > > > http://ocamlnet.sourceforge.net/intro/netchannels.html > > We're actually quite near to agree on what should be the minimal > requirements. > Looks like you included pos_in / pos_out into the "fundamentals methods" , > would you agree to drop theses ? I would not regard them as fundamental. Actually, they are derived, as they only count the characters flowing through input/output. (They have nothing to do with absolute file positions.) Of course, I don't remove them from ocamlnet, as they are very useful for that context. It is no problem to coerce them away, and to create them when needed by inheriting them from a virtual class. That won't complicate interoperability very much. > In short, I think we all want different things : > - Yamagata Yoriyuki want IO to be on a char basis (and that makes sense for > Unicode) > - you would prefer having buffered channels (and that make sense for network > protocols, parsing, ...) They can also be unbuffered, it is not specified. The nice thing about ocamlnet's channels is that you can add buffers when you need them, without changing the signature. Of course, the focus are buffered channels. > - I propose that we have two way of accessing the channel, that can be > buffered or unbuffered, or others. I think this is enough general to cover a > lot of different usage, and introduce some interesting polymorphism. > I would like to get your opinion on that. I guess you mean this one from a previous mail: class ['a,'b] input = object method read : 'a method nread : int -> 'b method close_in : unit end class ['a,'b,'c] output = object method write : 'a method nwrite : 'b method close_out : 'c end I doubt this is very practical. Consider you want to write Unicode characters into a file (I think a common example). The file as such is a byte stream, but you want an additional Unicode interface that converts implicitly to, say UTF-8. With your idea of generalised channel, the only way to do this is to build layers, something like let file_as_byte_channel = new file_out_channel "name" in let file_as_uni_channel = new convert_utf8_to_byte file_as_byte_channel Call file_as_byte_channel # write to output a byte, and call file_as_uni_channel # write to output a Unicode character. You don't have a single object that can do both, however. Even worse: If you want to use both interfaces alternately, you have to be careful to flush buffers at the right time (in the case there are buffers). I think it is better to have two methods, one for the polymorphic case, and one for strings. The latter plays a special role, simply because all I/O finally is string I/O. Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de ------------------------------------------------------------ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners