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 QAA29054; Thu, 15 Jul 2004 16:22:46 +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 QAA29292 for ; Thu, 15 Jul 2004 16:22:45 +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 i6FEMjEV005177 for ; Thu, 15 Jul 2004 16:22:45 +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 QAA28534 for ; Thu, 15 Jul 2004 16:22:44 +0200 (MET DST) Received: from basile by bourg.inria.fr with local (Exim 4.34) id 1Bl77m-0000E0-MD for caml-list@inria.fr; Thu, 15 Jul 2004 16:22:14 +0200 Date: Thu, 15 Jul 2004 16:22:14 +0200 To: caml-list@inria.fr Subject: Re: [Caml-list] kprintf with user formatters Message-ID: <20040715142214.GB28587@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> <20040715124223.GA28587@bourg.inria.fr> <20040715134530.GC11971@fichte.ai.univie.ac.at> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20040715134530.GC11971@fichte.ai.univie.ac.at> User-Agent: Mutt/1.5.6+20040523i From: "Basile Starynkevitch [local]" X-Miltered: at nez-perce with ID 40F69335.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 fmt:01 printf:01 kprintf:01 fmt:01 camlp:01 sourceforge:01 poesia:01 poesiasoft:01 runtime:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Jul 15, 2004 at 03:45:30PM +0200, Markus Mottl wrote: > On Thu, 15 Jul 2004, Basile Starynkevitch [local] wrote: > > I don't understand what this zprintf function should be, > > It should parse the format string, and ignore format arguments following > it. let zprintf fmt = Printf.kprintf (fun _ -> ()) fmt should be ok. But I think that the format string should not even be parsed. I've got no solution (except the one below) to this! > > I don't think that this hack will be too dangerous. You might get an > exception 'Invalid_argument "equal: functional value"' if you want to > compare those fancy unit-values, which is about the worst thing you > can achieve. But who would want to compare unit-values anyway? > > > 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/ > > The preprocessor is not good enough for me. I would like to change > log levels at runtime, because the application is a server which should > run permanently. The above hack was written with the same requirements, and provide the possibility to change log levels (or log flags actually). Actually, I more and more hate printf, both in C and in Ocaml. I really believe it is a nightmare. A possible suggestion might be to add a StopPrintf exception to Printf and add a tryprintf function to Printf, which takes a prologue function as an argument. If the prologue raises an exception, no formatting occur; otherwise, tryprintf works like kprintf -- 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