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-14 (05:27)
From: Dave Benjamin <dave@r...>
Subject: Name of currently executing function

Is there any way to find out the name of the currently executing 
function from within an OCaml program? I guess, technically, I'm 
interested in the grandparent. Something that would allow this:

let log msg =
   Printf.eprintf "%s: %s\n%!"
     (get_caller_function_name ())

I'm guessing the above is not possible, but perhaps there's some way to 
accomplish this using some combination of camlp4, back traces, 
profiling, or debugging?