From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.7 required=5.0 tests=MAILTO_TO_SPAM_ADDR, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 70673BC6B for ; Wed, 7 Nov 2007 04:40:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAF7CMEfAXQInh2dsb2JhbACOfgEICik X-IronPort-AV: E=Sophos;i="4.21,381,1188770400"; d="scan'208";a="4131894" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 07 Nov 2007 04:40:46 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id lA73ejIW007511 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 7 Nov 2007 04:40:46 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAF7CMEdIDtboi2dsb2JhbACOfgEIBAQTEQU X-IronPort-AV: E=Sophos;i="4.21,381,1188770400"; d="scan'208";a="19015923" Received: from hu-out-0506.google.com ([72.14.214.232]) by mail4-smtp-sop.national.inria.fr with ESMTP; 07 Nov 2007 04:40:39 +0100 Received: by hu-out-0506.google.com with SMTP id 16so976717hue for ; Tue, 06 Nov 2007 19:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=0U/Gu78ZTCysYETK9VnGTCY69DYDy2+XJgH5IWcaVfk=; b=Ktqw54XTDl4r9LJeMfJQq9A8UeOyz+YOqc6GwFe3iciH3sqb5NaGzcq/8sG638/Sx5AjZXl0pmJNGO3pIH2S8YikaQnPMIg466ymD6kZkoZEFKEcbrCkS+oQ5VwVWY802EF8X9QVpHO5ulLJsug08AuOfXoajnayKg2NkHGXT3U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=E+f+yNzwsjSBsMe4WPeR9lDYRlJsKtMj3yj2aHjFL6YGNBzUiJBTjsR20sDsBc5kQJwYYJZOjJA0g7RoMeQ86SHTzoI/qylBDy36zeBfUVBY+VtrVehBF6PCJPeSZsxkOudwkscfeRq7fbBX7XqjBj4Axk/9Czu05EMv7niEwIo= Received: by 10.78.132.2 with SMTP id f2mr5592878hud.1194406844493; Tue, 06 Nov 2007 19:40:44 -0800 (PST) Received: by 10.78.157.16 with HTTP; Tue, 6 Nov 2007 19:40:44 -0800 (PST) Message-ID: <4a051d930711061940ubf4aa40r6e41c54b910c5214@mail.gmail.com> Date: Tue, 6 Nov 2007 22:40:44 -0500 From: "Christopher L Conway" Sender: christopherleeconway@gmail.com To: caml-list@inria.fr Subject: Re: [Caml-list] log function without evaluate arguments In-Reply-To: <47309EEC.4080706@menta.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <47309EEC.4080706@menta.net> X-Google-Sender-Auth: 1316236f6ad1cd9a X-Miltered: at concorde with ID 473133BD.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 camlp:01 kprintf:01 camlp:01 syntax:01 val:01 printf:01 printf:01 sugestions:01 syntax:01 beginner's:01 ocaml:01 bug:01 callers:98 beginners:01 If you're using OCaml version <= 3.09, check out pa_log (http://www.cs.nyu.edu/~cconway/tools/index.html). I wrote it for exactly this purpose. Even if you're using 3.10, you might want to check it out. It's a really simple extension and updating it might be a good excuse to learn the new camlp4. Regards, Chris On 11/6/07, tmp123 wrote: > Hello, > > In order to implement a function that prints log messages only, by > example, if a boolean flag is true, and does nothing elsewhere, I've > been reading the (long) post sequence "kprintf with user formatters" > (2004 Jun 30). > > In this context, "does nothing" means not convert parameters to text nor > evaluate them. > > If my understanting of the reading has been correct, one of the best > options seems to be something like (in camlp4r revised syntax, I'm more > used to it): > > value log_flag = ref False; > > value log e = > if log_flag.val > then > Lazy.force e > else (); > > and the callers must include lines like: > > log (lazy (Printf.printf "%d" (sum 1 3))); > > Please, is this a good way? Some sugestions to made it better in > performance or syntax? > > Thanks a lot. > > > > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >