Skip to content

@michalmarczyk /intern-alias.clj
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
(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
Something went wrong with that request. Please try again.