Posted on May 17, 2014
A couple of notes regarding namespaces in Clojure
First of all:
- Namespaces must match the directory structure they’re in, all the way to the file;
requireis the basic way to import things.
(require 'clojure.string 'clojure.test)or even
(require '[clojure.string :as string])to be then used as (
useis used to refer to other namespaces’ functions as if they were in our namespace;
useis the function where
:onlycomes in – it says “only ditch the namespace of these symbols”;
- We can use
- We also have
importfor Java classes;
- And finally the
nsmacro where everything comes together inside.