Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2008-07-15 (06:13)
From: Dave Benjamin <dave@r...>
Subject: Re: [Caml-list] Name of currently executing function
blue storm wrote:
> Here is a little camlp4 code for an ad-hoc solution :

This works very well. Thank you very much for the example.

On a related note, I was trying to understand how these new syntax 
filters work, and I am a bit confused by how I'm supposed to use 
Camlp4Tracer. I tried compiling a simple test program with:

camlp4 -parser ocaml -filter tracer -printer ocaml

It complained about an unknown value "Debug.mode", which I figured out 
was in the Camlp4 library, so I added that library and the line:

module Debug = Camlp4.Debug

to my program. Then it complained about an unbound value "exc". I looked 
at the to discover that it expects an exception named 
"exc" to be in scope with every function. I'm not sure what this is for, 
but I was able to get it to compile by creating a toplevel variable. My 
test program looks like the following now:

(*pp camlp4 -parser ocaml -filter tracer -printer ocaml *)

module Debug = Camlp4.Debug

let exc = Not_found

let test () =
   print_endline "this is output"

let () =
   test ()

And my Makefile looks like this:


USE_CAMLP4 := yes
PACKS := camlp4.lib
RESULT := main


Now, I can get tracing output:

% CAMLP4_DEBUG=* ./main
camlp4-debug: tracer: Not_found at File "", line 8, characters 16-32
this is output

So, is this the way it's supposed to work? Is this exception supposed to 
be some sort of marker for logging purposes? It seems like maybe the 
Printexc stuff was accidentally pasted in from the 
Camlp4ExceptionTracer, but without any docs, it's hard to tell for sure.