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=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr 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 58A9CBBAF for ; Mon, 21 Jul 2008 01:41:53 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAOtpg0jOe3NG/2dsb2JhbACtHg X-IronPort-AV: E=Sophos;i="4.31,219,1215381600"; d="scan'208";a="15301101" Received: from spoomusic.com ([206.123.115.70]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Jul 2008 01:41:52 +0200 Received: (qmail 18054 invoked by uid 89); 20 Jul 2008 23:41:50 -0000 Received: from unknown (HELO ?192.168.1.99?) (98.165.129.233) by 0 with ESMTPS (DHE-RSA-AES256-SHA encrypted); 20 Jul 2008 23:41:50 -0000 Message-ID: <4883CD0C.3090504@ramenlabs.com> Date: Sun, 20 Jul 2008 16:41:00 -0700 From: Dave Benjamin User-Agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509) MIME-Version: 1.0 To: blue storm Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Name of currently executing function References: <487AE3A6.2080008@ramenlabs.com> <527cf6bc0807140653w6bb30b5nfa73e2e16462f181@mail.gmail.com> <488364FC.6010809@ramenlabs.com> <527cf6bc0807201035x7b16999eha0f4cc4d7f18995a@mail.gmail.com> In-Reply-To: <527cf6bc0807201035x7b16999eha0f4cc4d7f18995a@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ad-hoc:01 expr:01 functor:01 camlp:01 doable:01 camlp:01 functor:01 storm:98 wrote:01 caml-list:01 macros:01 macros:01 benjamin:01 explicitly:02 awkward:02 blue storm wrote: > Your combination of Profiler and Macros is really clever. I tried to do > something with macros before coming to the Profiler solution, but i > didn't work out. Thanks! The idea of using macros didn't occur to me until this morning. They certainly make it easier to work within the calling function's environment. > This solution is elegant because it integrates well with the other > program-wide macros ( __LOCATION__ and __FILE__ ), and more powerful > than the ad-hoc __LOG__ handling. Glad you think so. > The idea of directly modifying the decorate_this_expr declaration seemed > a little awkward at first, but it actually is as useful as the functor > solution (because all we can get anyway is the function name), while a > lot simpler. I think you could even suggest it for inclusion in the main > Camlp4 distribution (it should be doable to rebuild the old > Camlp4Profiler features on top of that). Well, I think you had the right idea in trying to generalize the profiler code so that it can be used for multiple purposes. I opted for the copy-and-modify approach mainly to keep the example small. My knowledge of camlp4 is pretty limited, and I have to admit I don't understand much of the profiler code. It's easier to suggest a slight modification than to write a new functor from scratch and then try to explain it. Exposing __FILE__ isn't quite enough to reproduce the Camlp4Profiler's functionality, since we also need a way to trigger some code to execute at the start of every function. Either that, or we introduce a new keyword (say, "PROFILE"), that has to be explicitly mentioned at the top of each function to be profiled. Dave