Created
April 11, 2012 19:53
-
-
Save pbalduino/2361951 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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