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 KAA13119; Thu, 15 Jul 2004 10:02:46 +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 KAA12901 for ; Thu, 15 Jul 2004 10:02:44 +0200 (MET DST) Received: from lri.lri.fr (lri.lri.fr [129.175.15.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6F82hSH018636 for ; Thu, 15 Jul 2004 10:02:44 +0200 Received: from localhost (localhost [127.0.0.1]) by lri.lri.fr (Postfix) with ESMTP id D071A19EB82; Thu, 15 Jul 2004 09:59:45 +0200 (CEST) Received: from lri.lri.fr ([127.0.0.1]) by localhost (lri.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23252-06; Thu, 15 Jul 2004 09:59:45 +0200 (CEST) Received: from pc8-123 (pc8-123 [129.175.8.123]) by lri.lri.fr (Postfix) with ESMTP id B750D19EB81; Thu, 15 Jul 2004 09:59:45 +0200 (CEST) Received: from filliatr by pc8-123 with local (Exim 3.35 #1 (Debian)) id 1Bl19d-0006vh-00; Thu, 15 Jul 2004 09:59:45 +0200 From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16630.14705.545286.299892@gargle.gargle.HOWL> Date: Thu, 15 Jul 2004 09:59:45 +0200 To: David MENTRE Cc: caml-list@inria.fr Subject: Re: [Caml-list] kprintf with user formatters In-Reply-To: <87fz7tybf6.fsf@linux-france.org> References: <20040630183237.457317c7@mostha> <200407142110.XAA25344@pauillac.inria.fr> <20040715001758.GF26614@fichte.ai.univie.ac.at> <87fz7tybf6.fsf@linux-france.org> X-Mailer: VM 7.03 under Emacs 20.7.2 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) X-Virus-Scanned: by amavisd-new at lri.fr X-Miltered: at concorde with ID 40F63A23.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; filliatre:01 filliatre:01 lri:01 caml-list:01 kprintf:01 formatters:01 fmt:01 fmt:01 val:01 kprintf:01 val:01 damien:01 printf:01 int:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk David MENTRE writes: > > > If the given log level "level" does not allow logging the message > > specified by "fmt", I just want to ignore the parameters provided together > > with "fmt" - but how? > > # let cur_level = ref 0;; > val cur_level : int ref = {contents = 0} > # let log level fmt = > let print_at_level str = if !cur_level >= level then print_string str in > Format.kprintf print_at_level fmt;; > val log : int -> ('a, unit, string, unit) format4 -> 'a = This solution still has the drawback of evaluating the whole message (which can be costly). Damien Pous's post has the expected behavior (printf arguments are simply discarded without any evaluation) but requires Obj.magic... -- Jean-Christophe ------------------- 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