My question is does Clojure program source code meta data exist, and is it easily accessible?
I was thinking of writing a function wrapper that would accept a function to call, a debug flag, and arbitrary text (location of the call in the source code, for example) to print when the debug flag is set. When clear, only the function would be called.
Rather than hard-code a position, I was wondering if that could be gleaned from the current function running. I do not know if such information is available. Otherwise, I can certainly supply arbitrary location information wherever the function is called.
Here is an example of such a function:
(defn test-fn
[]
(println "This is a test function."))
(defn fn-call-loc
[fn dbg-flag & locate-info]
(if (= 1 dbg-flag)
(println locate-info))
(fn))
repl-test.core=> (fn-call-loc test-fn 1 "Called from main.")
(Called from main.)
This is a test function.
nil
repl-test.core=>
My question is rather than my hard-coding "Called from main.", is there available meta data about the position at the location of the call to fn-call-loc?
Thanks.