-
-
Save amalloy/c93c37345c49c47dcfa2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro ? | |
"A useful debugging tool when you can't figure out what's going on: | |
wrap a form with ?, and the form will be printed alongside | |
its result. The result will still be passed along." | |
[val] | |
`(let [x# ~val] | |
(prn '~val '~'is x#) | |
x#)) |
Right. And I also tend to rewrite such a little function, since it's even easier than trying to remember in what clojure contrib it lives, grab the dependency if I don't have it yet ... such a little function could maybe have its place somewhere in clojure core ? clojure.core, or clojure.repl ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, spy does this, but imo not as well. It uses (str '~expr) for one thing, instead of pr-str, which makes it hard to tell exactly what types things are. It also outputs to the debug log, which requires that you configure logging for your program. Most of the time I don't want to bother with that.