Skip to content

Instantly share code, notes, and snippets.

View xumingming's full-sized avatar

James Xu xumingming

  • -
  • -
View GitHub Profile
@xumingming
xumingming / dbg.clj
Created April 17, 2012 09:45
clojure debug macro
(defmacro dbg[x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))
;;; See the inspirational SO question: http://stackoverflow.com/questions/3346382
(require 'clojure.contrib.trace)
(defn trace-ns
"Replaces each function from the given namespace with a version wrapped
in a tracing call. Can be undone with untrace-ns. ns should be a namespace
object or a symbol."
[ns]
(doseq [s (keys (ns-interns ns))
(try ....
(catch Exception e
(println e)))