For those wondering, as I did, what the difference between clojure.repl/source
and clojure.repl/source-fn
is, source
is a macro that prints the source code of a given function directly to standard out, and actually uses source-fn
, whereas source-fn
is a function that returns a string representation of the given function.
Both require that the function be given as a symbol that resolves to a Var defined in a namespace for which the .clj is in the classpath. This is why it is necessary to first get the name of the function, demunge it (e.g. (clojure.repl/demunge "clojure.core$_PLUS_") => "clojure.core/+"
), and then convert it to a symbol before passing it as an argument as @borkdude showed in his answer.