I’m looking for the ability to have the REPL print the current definition of a function. Is there any way to do this?
For example, given:
(defn foo [] (if true "true"))
I’d like to say something like
(print-definition foo)
and get something along the lines of
(foo [] (if true "true"))
printed.
An alternative to
source(which should be available viaclojure.repl/sourcewhen starting a REPL, as of1.2.0. If you’re working with1.1.0or lower,sourceis inclojure.contrib.repl-utils.), for REPL use, instead of looking at functions defined in a.cljfile:A simple
print-definition:#'is just a reader macro, expanding from#'footo(var foo):