- Cider NREPL debugger
- clojure.tools.trace
- #dbg
- :break/when metadata
- pre- and post-conditions
- clojure.spec
println
for a line of human-readable outputprn
for a line ofclojure-core.read
ablepprint
for multi-line values
- Demonstrate
- support fluid method calls
- Demonstrate
http://www.learningclojure.com/2010/09/astonishing-macro-of-narayan-singhal.html
(defmacro def-let
[bindings & more]
(let [let-expr (macroexpand `(let ~bindings))
names-values (partition 2 (second let-expr))
defs (map #(cons 'def %) names-values)]
(concat (list 'do) defs more)))
Add (debug->> LABEL) to a -> form to print [LABEL CURRENT] where CURRENT is the threaded value at that step.
(require '[clojure.pprint :refer [pprint]])
(defn dump->
"Pretty-print [LABEL OBJECT] from a -> form when debugging."
[object label]
(pprint [label object])
object)
Add (debug->> LABEL) to a ->> form to print [LABEL CURRENT] where CURRENT is the threaded value at that step.
(require '[clojure.pprint :refer [pprint]])
(defn dump->>
"Pretty-print [LABEL OBJECT] from a ->> form when debugging."
[label object]
(pprint [label object])
object)
(defmacro dump
"Dump a vector [LABEL VALUE] where FORM is the EXPRESSION source
and VALUE is its value."
[expression]
`(let [x# ~expression]
(do
(println ['~expression x#])
x#)))
(defmacro debug-do [& body]
(when *debug*
`(do ~@body)))
(dotimes [i 10]
#dbg ^{:break/when (= i 7)}
(prn i))