Created
April 1, 2013 17:51
-
-
Save alexhall/5286484 to your computer and use it in GitHub Desktop.
declaring dynamic functions
This file contains 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
;; internal helper function | |
(defn default-foo [] "Hello, world!") | |
;; public API | |
(def ^:dynamic *foo* default-foo) | |
(defn bar [] (*foo*)) | |
;; Usage | |
(bar) | |
(binding [*foo* #("Goodbye, world!")] | |
(bar)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment