Created
May 17, 2022 13:27
-
-
Save borkdude/5ee5bd641270dbb641e3e3e379347325 to your computer and use it in GitHub Desktop.
export macro
This file contains hidden or 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