I wanted to write a function like this:
(defn fn-name-info
"Given a function, try to deduce the function name and clojure namespace by looking
at the function's java class name and decoding stuff. Return a vector of name, namespace strings,
or nil if we can't find anything.
For example, if in jdt.core we do (defn foo []), the resulting value foo is a thing whose class is
jdt.core$foo, for which we can return [\"jdt.core\" \"foo\"].
However, for anonymous functions like (fn []) typed into the REPL,
you're going to get something like [\"jdt.core\" \"eval3676$fn__3677\"]"
[f]
)
Surely someone out there has a bit of code that knows how to decode classnames accounting for
many of the weird edge cases, question marks (e.g. "QMARK"), and so on?
Can anybody help me out?
FYI, the next step I had planned for this was for me to reach take that fn information, look for the var that defines it, and yank out some metadata, when all I have is the function pointer, not the var.
Tips appreciated.
Yes, I know it's probably a bad idea for a couple of reasons, but feel free to point them out.