I'm having a hard time understanding (and therefore remembering) the clojure require syntax described here: http://clojuredocs.org/clojure_core/1.3.0/clojure.core/require. It seems both counter intuitive and non-uniform.
For example, in the following why is this vector required to be quoted:
(require '[clj-json.core :as json])
Counter intuitive because normally vectors are not quoted in clojure (lists are quoted and vectors are treated as data).
And non-uniform because in this case the vector is NOT quoted:
(ns xxx
(:require [clj-json.core :as json]))
I realize that the require function and the :require
usage inside the ns macro are only optically similar, but still.
There are other pieces of weirdness as well, for example I can do this:
(require '(clj-json.core))
But I can't do this:
(require '(clj-json.core :as json))
Can someone answer these questions:
- in the first example why does the vector need to be quoted?
- why does it not need to be quoted in the ns macro?
- why does the list notation not allow
:as
?
I'm wondering if there's reasons why things are the way they are, or if the inconsistency was just not noticed at design time.