May 2018
Beginner to intermediate
290 pages
6h 43m
English
Like symbols and vars, namespaces are just ordinary Clojure values, accessible to the mortal Clojure programmer. You can, for example, get at the current namespace: it’s always bound to the symbol *ns*, so that
| | (println "Current ns:" *ns*) |
will print something like
| | Current ns: #object[clojure.lang.Namespace 0x76c706bf user] |
You can also look up any existing namespace by name:
| | (find-ns 'user) ; Get the namespace called 'user. |
With a namespace in hand, you can discover all the things defined in that namespace, so that this:
| | (ns-map (find-ns 'user)) ; Includes all the predefined vars. |
will give you a very large map of symbols to vars, essentially everything the user namespace knows about:
| | {primitives-classnames ... |
Read now
Unlock full access