Loading Namespaces

While namespaces are conceptually simple, especially if you’re working in the REPL, things do get a bit more complicated when you want to use namespaces that are stored in .clj files—either files you have written or those authored by others. The rub is that you need to ensure that Clojure knows to read the .clj file and compile it into a namespace that you can use. In short, you need to make sure the namespace you want to use is loaded before you try to use it.

For example, your Clojure installation comes equipped with a ready-made namespace called clojure.data. The clojure.data namespace—and the period is part of the name—contains a handy function called diff, which will compare two data structures, perhaps vectors, and ...

Get Getting Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.