Organizing with Namespaces

Clojure code is compiled and evaluated as a series of individual top-level forms (functions, records, protocols, and so on), but Clojure provides namespaces to group those individual forms. Namespaces are named, hierarchical containers that we can use to collect, organize, and name groups of forms. One practical use of namespaces is to allow us to use simple names in our code without worrying that we’ll conflict with the same name somewhere else. The namespace provides a means of specifying which one we mean.

Although Clojure code is made up of finer-grained elements, dependencies are declared and loaded at the namespace level, not at the function level. The ns macro in each namespace defines its dependencies, collectively ...

Get Clojure Applied now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.