Skip to content

Instantly share code, notes, and snippets.

@michalmarczyk
Created July 6, 2010 03:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save michalmarczyk/464970 to your computer and use it in GitHub Desktop.
(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