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-20 (16:17)
From: Dave Benjamin <dave@r...>
Subject: Re: [Caml-list] Name of currently executing function
Thanks again for your help, blue storm. I condensed this technique into 
a simple example for PLEAC, which I just committed here:

It allows you to write this:

(* An example named function. *)
let test_function () =
   let str = "Hello, world!" in
   let num = 42 in
   LOG "str=\"%s\", num=%d" str num;
   print_endline "test complete"

(* Some code to run at the toplevel. *)
let () =
   LOG "not in a function";
   test_function ()

And get the following output:

<toplevel>[]: not in a function
test_function[]: str="Hello, world!", num=42
test complete