Version française
Home     About     Download     Resources     Contact us    
Browse thread
Name of currently executing function
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dave Benjamin <dave@r...>
Subject: Re: [Caml-list] Name of currently executing function
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