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 OAA23653; Thu, 15 Jul 2004 14:42:56 +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 OAA23387 for ; Thu, 15 Jul 2004 14:42:55 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i6FCgsEV025182 for ; Thu, 15 Jul 2004 14:42:54 +0200 Received: from bourg.inria.fr (bourg.inria.fr [128.93.11.100]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA21842 for ; Thu, 15 Jul 2004 14:42:54 +0200 (MET DST) Received: from basile by bourg.inria.fr with local (Exim 4.34) id 1Bl5ZA-0007Uk-1p for caml-list@inria.fr; Thu, 15 Jul 2004 14:42:24 +0200 Date: Thu, 15 Jul 2004 14:42:24 +0200 To: caml-list@inria.fr Subject: Re: [Caml-list] kprintf with user formatters Message-ID: <20040715124223.GA28587@bourg.inria.fr> References: <20040630183237.457317c7@mostha> <200407142110.XAA25344@pauillac.inria.fr> <20040715001758.GF26614@fichte.ai.univie.ac.at> <20040715093953.53769963@mostha> <20040715121945.GA11971@fichte.ai.univie.ac.at> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20040715121945.GA11971@fichte.ai.univie.ac.at> User-Agent: Mutt/1.5.6+20040523i From: "Basile Starynkevitch [local]" X-Miltered: at nez-perce with ID 40F67BCE.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 kprintf:01 formatters:01 basile:01 basile:01 2004:99 damien:01 fmt:01 printf:01 printf:01 fmt:01 val:01 eats:01 -rectypes:01 'b-:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Jul 15, 2004 at 02:19:47PM +0200, Markus Mottl wrote: > On Thu, 15 Jul 2004, Damien wrote: > > I had the same problem a month ago, > > I ended with the following ugly function: > > > > let log b fmt = > > if b then Printf.printf fmt > > else > > let rec f x = Obj.magic f in > > f fmt > > (* val f: bool -> ('a, out_channel, unit) format -> 'a *) > > > > (I think this is safe since f just eats its arguments, > > and gets typed with "-rectypes" : ('b->'a) as 'a) > > > > maybe a function "zprintf" could be added to Printf and Format to do > > this job ? I don't understand what this zprintf function should be, but the above log proposal behave strangely (and perhaps unsafely) : # log false "a=%d s=%S\n%!" 1 "xyz";; - : unit = For what it's worth, long time ago, I ended writing a camlp4 extension for a similar logging (or tracing purpose) see file README.trace and pa_trace.ml of http://cvs.sourceforge.net/viewcvs.py/poesia/PoesiaSoft/PoesiaMonIcap/ Regards. -- Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr Project cristal.inria.fr - phone +33 1 3963 5197 - mobile 6 8501 2359 http://cristal.inria.fr/~starynke --- all opinions are only mine ------------------- 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