Skip to content

Instantly share code, notes, and snippets.

@pbalduino
Created April 11, 2012 19:53
Show Gist options
  • Save pbalduino/2361951 to your computer and use it in GitHub Desktop.
Save pbalduino/2361951 to your computer and use it in GitHub Desktop.
(defn setup []
println "Yes, we have setup!")
(defmacro run-if-exists [name]
`(if (clojure.test/function? '~name)
((println "Calling function")
~name)
(println "Function not found")))
(macroexpand '(run-if-exists setup))
; (if (clojure.test/function? (quote setup)) ((clojure.core/println "Calling function") setup) (clojure.core/println "Function not found"))
(run-if-exists setup)
; Calling function
; java.lang.NullPointerException (NO_SOURCE_FILE:0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment