Changes for clojure.core/ns-publics

jafingerhut on Thu, 24 Feb 2011
;; create the namespace and switch to it
user=> (in-ns 'demo.ns)
#<Namespace demo.ns>

;; Make sure all of the good stuff in clojure.core is usable here, too.
demo.ns=> (clojure.core/use 'clojure.core)
nil

;; define some public functions
demo.ns=> (defn public-fn1 [x y] (+ x y))
#'demo.ns/public-fn1
demo.ns=> (defn public-fn2 [t] (* t t t))
#'demo.ns/public-fn2

;; define a private function with defn-
demo.ns=> (defn- private-fn [s] (/ s 5))
#'demo.ns/private-fn

;; Switch back to the user namespace
demo.ns=> (in-ns 'user)
#<Namespace user>

;; Get a map of all intern mappings for namespace demo.ns
user=> (ns-interns 'demo.ns)
{public-fn1 #'demo.ns/public-fn1, private-fn #'demo.ns/private-fn, public-fn2 #'demo.ns/public-fn2}

;; Now get a map of only the public mappings.  No private-fn here.
user=> (ns-publics 'demo.ns)
{public-fn1 #'demo.ns/public-fn1, public-fn2 #'demo.ns/public-fn2}
jafingerhut on Thu, 24 Feb 2011
user=> (in-ns 'demo.ns)
#<Namespace demo.ns>
demo.ns=> (clojure.core/use 'clojure.core)
nil
demo.ns=> (defn public-fn1 [x y] (+ x y))
#'demo.ns/public-fn1
demo.ns=> (defn public-fn2 [t] (* t t t))
#'demo.ns/public-fn2
demo.ns=> (defn- private-fn [s] (/ s 5))
#'demo.ns/private-fn
demo.ns=> (in-ns 'user)
#<Namespace user>
user=> (ns-interns 'demo.ns)
{public-fn1 #'demo.ns/public-fn1, private-fn #'demo.ns/private-fn, public-fn2 #'demo.ns/public-fn2}
user=> (ns-publics 'demo.ns)
{public-fn1 #'demo.ns/public-fn1, public-fn2 #'demo.ns/public-fn2}
jafingerhut on Thu, 24 Feb 2011
user=> (ns-publics 'clojure.xml)
{content-handler #'clojure.xml/content-handler, *stack* #'clojure.xml/*stack*, attrs #'clojure.xml/attrs, element #'clojure.xml/element, tag #'clojure.xml/tag, startparse-sax #'clojure.xml/startparse-sax, *current* #'clojure.xml/*current*, content #'clojure.xml/content, *state* #'clojure.xml/*state*, parse #'clojure.xml/parse, emit-element #'clojure.xml/emit-element, *sb* #'clojure.xml/*sb*, emit #'clojure.xml/emit}

user=> (sort (keys (ns-publics 'clojure.xml)))
(*current* *sb* *stack* *state* attrs content content-handler element emit emit-element parse startparse-sax tag)