Created
March 3, 2015 01:56
-
-
Save Chouser/c7ccb513ac3daa2dfa70 to your computer and use it in GitHub Desktop.
Tag a function to make it available with multiple prefixes.
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
(defn tag [tags the-var] | |
(binding [*ns* nil] | |
(doseq [tag tags] | |
(intern (in-ns tag) (.sym the-var) @the-var)))) | |
(tag '[A B C] | |
(defn foo [a b] | |
(+ a b))) | |
(A/foo 5 10) | |
;=> 15 | |
(C/foo 20 22) | |
;=> 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment