English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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?