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 OAA22168; Thu, 15 Jul 2004 14:19:52 +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 OAA22551; Thu, 15 Jul 2004 14:19:50 +0200 (MET DST) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i6FCJnEV022290; Thu, 15 Jul 2004 14:19:49 +0200 Received: from fichte.ai.univie.ac.at (markus@localhost [127.0.0.1]) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian-6.6) with ESMTP id i6FCJmDu014405; Thu, 15 Jul 2004 14:19:48 +0200 Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian-6.6) id i6FCJl4A014404; Thu, 15 Jul 2004 14:19:47 +0200 Date: Thu, 15 Jul 2004 14:19:47 +0200 From: Markus Mottl To: Damien Cc: caml-bugs , OCaml Subject: Re: [Caml-list] kprintf with user formatters Message-ID: <20040715121945.GA11971@fichte.ai.univie.ac.at> Mail-Followup-To: Damien , caml-bugs , OCaml References: <20040630183237.457317c7@mostha> <200407142110.XAA25344@pauillac.inria.fr> <20040715001758.GF26614@fichte.ai.univie.ac.at> <20040715093953.53769963@mostha> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040715093953.53769963@mostha> User-Agent: Mutt/1.5.6i X-Miltered: at nez-perce with ID 40F67665.001 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 damien:01 fmt:01 printf:01 printf:01 fmt:01 val:01 eats:01 -rectypes:01 'b-:01 -rectypes:01 bool:01 rec:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 ? Thanks for the hint, this works for me! I also think that there should be some kind of "zprintf"-function in the standard library. Forcing people to use "-rectypes" or "Obj.magic" is evil. Regards, Markus -- Markus Mottl http://www.oefai.at/~markus markus@oefai.at ------------------- 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