Created
July 6, 2010 03:47
-
-
Save michalmarczyk/464970 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 intern-alias | |
"Interns a Var called alias-sym in the namespace given by ns-or-sym | |
(which may be a symbol or an actual namespace object; defaults to | |
the current namespace). The binding of the new Var will be that of | |
the Var specified as var-or-sym; also, all metadata is copied from | |
the original to the alias. The original may be specified as either | |
a Var or a symbol." | |
([alias-sym var-or-sym] | |
(intern-alias *ns* alias-sym var-or-sym)) | |
([ns-or-sym alias-sym var-or-sym] | |
(let [n (the-ns ns-or-sym) | |
v (if (symbol? var-or-sym) | |
(resolve var-or-sym) | |
var-or-sym)] | |
(intern n (with-meta alias-sym (meta v)) @v)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment