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 TAA32150; Fri, 16 Jul 2004 19:57:00 +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 TAA31803 for ; Fri, 16 Jul 2004 19:56:59 +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 i6GHuwEV018983 for ; Fri, 16 Jul 2004 19:56:58 +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 i6GHuwDu004297 for ; Fri, 16 Jul 2004 19:56:58 +0200 Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian-6.6) id i6GHuwbZ004296 for caml-list@inria.fr; Fri, 16 Jul 2004 19:56:58 +0200 Date: Fri, 16 Jul 2004 19:56:58 +0200 From: Markus Mottl To: OCaml Subject: Re: [Caml-list] kprintf with user formatters Message-ID: <20040716175658.GE741@fichte.ai.univie.ac.at> Mail-Followup-To: OCaml References: <20040715093953.53769963@mostha> <200407160602.IAA00723@pauillac.inria.fr> <20040716104231.5497af93@mostha> <20040715142214.GB28587@bourg.inria.fr> <200407160647.IAA02290@pauillac.inria.fr> <16631.32784.526557.747099@gargle.gargle.HOWL> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040716104231.5497af93@mostha> <16631.32784.526557.747099@gargle.gargle.HOWL> User-Agent: Mutt/1.5.6i X-Miltered: at nez-perce with ID 40F816EA.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 filliatre:01 higher-order:01 val:01 damien:01 overkill:01 printf:01 printf:01 allocations:01 debug:01 closure:01 mottl:02 mottl:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 16 Jul 2004, Jean-Christophe Filliatre wrote: > I also use the same kind of trick in practice, with a little > refinement to avoid building the closure. I introduce higher-order > functions such as > > val if_debug : ('a -> unit) -> 'a -> unit This actually looks quite nice to me! Though one needs to add several functions for varying numbers of arguments, this makes hardly any difference syntactically, and it is still sufficiently easy to maintain. On Fri, 16 Jul 2004, Damien wrote: > > It is overkill to introduce a new printf function just for that case. > maybe... > but it is not to hard to implement (after a quick look at printf.ml) > without the "invalid unit value" problem: Yes, a change like this in the Printf/Format-implementation was what I was thinking about. Just count the number of arguments in the format and discard them. This is sufficiently efficient (no allocations) and convenient. 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