Search code examples
clojure

clojure definition of list in source code


I was browsing the clojure source code this morning, and near the top of clojure/core.clj I found this:

(def
    ^{:arglists '([& items])
      :doc "Creates a new list containing the items."
      :added "1.0"}
    list (. clojure.lang.PersistentList creator))

The thing that looks odd to me is the symbol creator. It doesn't appear anywhere in the file above it. Why is that not a problem?


Solution

  • The dot special form is used for java interop. Since clojure.lang.PersistentList is a class name symbol,

    (. clojure.lang.PersistentList creator)
    

    is an access of the static creator field.

    https://github.com/clojure/clojure/blob/clojure-1.8.0/src/jvm/clojure/lang/PersistentList.java#L66