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
Thanks again for your help, blue storm. I condensed this technique into 
a simple example for PLEAC, which I just committed here:

http://pleac.cvs.sourceforge.net/pleac/pleac/pleac/pleac_ocaml.data?r1=1.151&r2=1.152

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>[main.ml]: not in a function
test_function[main.ml]: str="Hello, world!", num=42
test complete

Regards,
Dave