public
Last active

  • Download Gist
intern-alias.clj
Clojure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
(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))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.