export macro
This file contains 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
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/export | |
foo=> (defn foo []) | |
#'foo/foo | |
foo=> (defn bar []) | |
#'foo/bar | |
foo=> (export foo) | |
nil | |
foo=> (ns bar) | |
nil | |
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