Skip to content

Instantly share code, notes, and snippets.

@senior
Created February 23, 2013 15:31
Show Gist options
  • Select an option

  • Save senior/5020145 to your computer and use it in GitHub Desktop.

Select an option

Save senior/5020145 to your computer and use it in GitHub Desktop.
(defmacro dbg (form)
(let ((res (make-symbol "res"))
(dbg-str (make-symbol "dbg-str")))
`(progn
(let ((,res ,form))
(let ((,dbg-str (concat
(prin1-to-string "Debugging--> ")
(prin1-to-string ',form)
(prin1-to-string "\n = ")
(prin1-to-string ,res))))
(message ,dbg-str)
,res)))))
(dbg (+ 1 1))
-> 2
*Messages*
"Debugging--> "(+ 1 1)"
= "2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment