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 BAA21549; Fri, 16 Jul 2004 01:36:03 +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 BAA20754 for ; Fri, 16 Jul 2004 01:36:02 +0200 (MET DST) Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.249]) by nez-perce.inria.fr (8.12.10/8.12.10) with SMTP id i6FNa0EV031481 for ; Fri, 16 Jul 2004 01:36:01 +0200 Received: by mproxy.gmail.com with SMTP id q44so1821305cwc for ; Thu, 15 Jul 2004 16:35:58 -0700 (PDT) Received: by 10.11.118.46 with SMTP id q46mr86734cwc; Thu, 15 Jul 2004 16:35:58 -0700 (PDT) Message-ID: Date: Fri, 16 Jul 2004 01:35:58 +0200 From: henri dubois-ferriere To: Jean-Christophe Filliatre Subject: Re: [Caml-list] kprintf with user formatters Cc: David MENTRE , caml-list@inria.fr In-Reply-To: <16630.14705.545286.299892@gargle.gargle.HOWL> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20040630183237.457317c7@mostha> <200407142110.XAA25344@pauillac.inria.fr> <20040715001758.GF26614@fichte.ai.univie.ac.at> <87fz7tybf6.fsf@linux-france.org> <16630.14705.545286.299892@gargle.gargle.HOWL> X-Miltered: at nez-perce with ID 40F714E0.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; henridf:01 caml-list:01 kprintf:01 formatters:01 printf:01 2004:99 filliatre:01 filliatre:01 lri:01 fmt:01 fmt:01 val:01 kprintf:01 val:01 damien:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk any idea how this would compare (performance-wise) to building a closure (fun () -> printf ...) , and then evaluating the closure only when the debug level is ok? henri On Thu, 15 Jul 2004 09:59:45 +0200, Jean-Christophe Filliatre wrote: > > 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 > ------------------- 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