let Sigmund () =
System.Reflection.MethodBase.GetCurrentMethod().Name
let Donald () =
System.Reflection.MethodBase.GetCurrentMethod().Name
let Eustachio () =
System.Reflection.MethodBase.GetCurrentMethod().Name
let get_name_of_x (x: unit -> unit) =
()
let x =
[|
Sigmund
Donald
Eustachio
|]
x |> Array.iter (fun x -> x() |> printfn "%s")
Since functions can see their name, I know that it should be possible to get the name of the function passed to get_name_of_x, but I cannot figure out how to do this. Being able to do this would be helpful when writing my own testing library.
Fuchu , for example, does not separate names directly from functions, and using DU for composition instead of functions makes it less flexible than it could be, so it might be worth improving.
source
share