I need to get calling function name in Clojure. Something like combination of macro's implicit variable &form and *file* var. I need to get or infer function name from those variable or something else if possible. Will have to be non platform specific.
2 Answers
This function already exists in the Tupelo library. There are two functions that are thin wrappers over tupelo.misc/stacktrace-info
They return a map of info about the current function (or its parent), like:
{:ns-name 'demo.core'
:fn-name 'add2'
:class-name 'demo.core$add2'
:file-name 'core.clj'
:line-num 57
:method-name 'invokeStatic' }