From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id C476EBC3F for ; Fri, 29 Oct 2004 12:13:24 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i9TADONA013558 for ; Fri, 29 Oct 2004 12:13:24 +0200 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 MAA32452 for ; Fri, 29 Oct 2004 12:13:24 +0200 (MET DST) Received: from publilogics.com (pouic.publilogics.com [213.186.50.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id i9TADNPq008146 for ; Fri, 29 Oct 2004 12:13:23 +0200 Received: (qmail 5424 invoked from network); 29 Oct 2004 10:13:22 -0000 Received: from unknown (HELO PWARP) ([61.213.94.147]) (envelope-sender ) by pouic.publilogics.com (qmail-ldap-1.03) with SMTP for ; 29 Oct 2004 10:13:22 -0000 Message-ID: <001701c4bd9f$d68bc370$0b05a8c0@PWARP> From: "Nicolas Cannasse" To: "Diego Olivier Fernandez Pons" , References: Subject: Re: [Caml-list] Pervasives 'general output functions' Date: Fri, 29 Oct 2004 19:12:44 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Miltered: at concorde with ID 418217C4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 418217C3.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 pervasives:01 redirected:01 pervasives:01 printf:01 endian:01 binary:01 fprintf:01 printf:01 'x':01 lib:01 newlines:01 ....:98 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: > Bonjour, > > I would like a Caml program to output some information to an output > channel and according to my needs this channel be redirected to > - a (human readable) file > - the standard output > - a black hole > > The "general output functions" section of Pervasives seem to be what I > need but it hasn't the same signature than "Output functions on > standard output" Generic IO from ExtLib are dealing with this problem, and have a printf functionnality. They also have useful functions such as write_i16 / write_ui32 .... (in low and big endian) when dealing with C binary files. > I suspect I could just compose with string_of_X functions to obtain > the same result. There is also an awful [fprintf] function inherided > from C but I am still trying to understand the doc (never understood > C's either). printf "%d %f %s %c" 33 1.234 "hello" 'x' > Why haven't the equivalent functions been added to the standard lib to > allow a drop in replacement ? Maybe because printf allows you to specify precision for int/floats as well as newlines ? Nicolas