Skip to content

Instantly share code, notes, and snippets.

Created May 17, 2022
What would you like to do?
export macro
foo=> (defmacro export [& var-names]
(let [var-names (set var-names)]
(doseq [[k v] (ns-publics *ns*)]
(when-not (contains? var-names k)
(alter-meta! v assoc :private true)))))
foo=> (defn foo [])
foo=> (defn bar [])
foo=> (export foo)
foo=> (ns bar)
bar=> foo/foo
#object[foo$foo 0x5ecba515 "foo$foo@5ecba515"]
bar=> foo/bar
Syntax error (IllegalStateException) compiling at (REPL:0:0).
var: foo/bar is not public
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment