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 PAA14069; Fri, 9 Apr 2004 15:44:40 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA14861 for ; Fri, 9 Apr 2004 15:44:39 +0200 (MET DST) Received: from waco.inria.fr (waco.inria.fr [128.93.25.2]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i39DiaYM011108; Fri, 9 Apr 2004 15:44:37 +0200 Received: from waco.inria.fr (localhost [127.0.0.1]) by waco.inria.fr (8.12.10/8.12.10) with ESMTP id i39Dia3Z015465; Fri, 9 Apr 2004 15:44:36 +0200 Received: (from verlyck@localhost) by waco.inria.fr (8.12.10/8.12.10/Submit) id i39DiaO9015464; Fri, 9 Apr 2004 15:44:36 +0200 Date: Fri, 9 Apr 2004 15:44:36 +0200 Message-Id: <200404091344.i39DiaO9015464@waco.inria.fr> To: jgoerzen@complete.org CC: caml-list@inria.fr In-reply-to: <20040408175519.GB1291@excelhustler.com> (jgoerzen@complete.org) Subject: Re: [Caml-list] Dynamically evaluating OCaml code From: Bruno.Verlyck@inria.fr References: <20020104004356.GA1672@mev> <20040408133727.GC29195@excelhustler.com> <20040408145606.GA18473@fichte.ai.univie.ac.at> <20040408153056.GB30763@excelhustler.com> <200404081644.i38GiFlK012282@waco.inria.fr> <20040408175519.GB1291@excelhustler.com> Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 dynamically:01 2004:99 2004:99 openfile:01 pervasives:01 buffering:01 pervasives:01 posix:01 sus:99 fflush:01 positioning:99 positioning:99 error-prone:01 buffering:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 215 Date: Thu, 8 Apr 2004 12:55:19 -0500 From: John Goerzen On Thu, Apr 08, 2004 at 06:44:15PM +0200, Bruno.Verlyck@inria.fr wrote: > - read-write file handles: You can get them with Unix.openfile > and Unix.dup. Then with Unix.{in,out}_channel_of_descr, you > can use the Pervasives I/O functions. I have discovered that, but it seems that I don't fully understand the buffering semantics over on the Pervasives side. For instance, it's not entirely clear what happens if I write something to an out channel, then seek somewhere via that channel, then read via the other channel. The results have not always been what I expected. You aren't a lot better in C. What does Posix/SUS V2 says for fopen ? When a file is opened with update mode (+ as the second or third character in the mode argument), both input and output may be performed on the associated stream. However, output must not be directly followed by input without an intervening call to fflush() or to a file positioning function (fseek, fsetpos() or rewind()), and input must not be directly followed by output without an intervening call to a file positioning function, unless the input operation encounters end-of-file. This is error-prone at least. As for OCaml buffering semantics: - you begin to understand why there's no read-write channel: a lot of complexity for a seldom used functionality; - those having been banned, the OCaml I/O system makes no effort to ease things for you: the two channels are independently buffered, they don't known of each other, reading won't see your last modifications if nothing forces an update of the buffer. Beware: this is what I remember, io.c is of course the ultimate reference. (Pervasives appears to sometimes make an underlying call to read or write a different number of bytes than I requested -- which can be This is called (you guessed it) buffering. a problem for network protocols where this can cause deadlock) If it gets in your way, don't use Pervasives (but Unix.{read,write}). > - string handling: look at my (rather full-featured) Cstr library > (http://pauillac.inria.fr/cash/cstr/); That looks great. Has a lot of stuff I'd use. It looks like it's separate from cash; is that correct? (If so, I'll package it up for Debian right away ) That's correct. Thank you for the packaging. Some bugs are fixed in the CVS version (hopefully none introduced.. :-). Bruno. ------------------- 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