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.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id D6F68BC6B for ; Tue, 6 Nov 2007 17:11:20 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAB8hMEfAXQImh2dsb2JhbACOfgEICik X-IronPort-AV: E=Sophos;i="4.21,378,1188770400"; d="scan'208";a="5514142" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 06 Nov 2007 17:11:20 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id lA6GBJko032035 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 6 Nov 2007 17:11:20 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAB8hMEc+F9Qbn2dsb2JhbACOfgEBBwQGCQgY X-IronPort-AV: E=Sophos;i="4.21,378,1188770400"; d="scan'208";a="5514141" Received: from smail5.alcatel.fr ([62.23.212.27]) by mail3-smtp-sop.national.inria.fr with ESMTP; 06 Nov 2007 17:11:19 +0100 Received: from esmail03.netfr.alcatel.fr (esmail03.netfr.alcatel.fr [155.132.182.218]) by smail5.alcatel.fr (8.13.4/8.13.4/ICT) with ESMTP id lA6GA2FD029599 for ; Tue, 6 Nov 2007 17:10:02 +0100 Received: from [159.23.98.76] ([159.23.98.76]) by esmail03.netfr.alcatel.fr (Lotus Domino Release 5.0.13aHF163) with ESMTP id 2007110617111629:1872 ; Tue, 6 Nov 2007 17:11:16 +0100 Message-ID: <47309EEC.4080706@menta.net> Date: Tue, 06 Nov 2007 17:05:48 +0000 From: tmp123 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: log function without evaluate arguments X-MIMETrack: Itemize by SMTP Server on ESMAIL03/ES/ALCATEL(Release 5.0.13aHF163 | June 23, 2005) at 11/06/2007 17:11:16, Serialize by Router on ESMAIL03/ES/ALCATEL(Release 5.0.13aHF163 | June 23, 2005) at 11/06/2007 17:11:16, Serialize complete at 11/06/2007 17:11:16 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Scanned-By: MIMEDefang 2.51 on 155.132.188.13 X-Miltered: at discorde with ID 47309227.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; kprintf:01 camlp:01 syntax:01 val:01 printf:01 printf:01 sugestions:01 syntax:01 callers:98 boolean:01 lazy:02 lazy:02 revised:02 seems:03 parameters:03 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.