February 2018
Intermediate to advanced
304 pages
7h 11m
English
One of the most important tools in a programming language is the ability to name and remember values or functions for later use. In Clojure, a namespace is a collection of names (symbols) that refer to vars. Each var is bound to a value. Let’s consider vars more closely.
When you define an object with def or defn, that object is stored in a Clojure var. For example, the following def creates a var named user/foo:
| | (def foo 10) |
| | -> #'user/foo |
The symbol user/foo refers to a var that is bound to the value 10. If you ask Clojure to evaluate the symbol foo, it will return the value of the associated var:
| | foo |
| | -> 10 |
The initial value of a var is called its root binding. Sometimes it’s useful to have thread-local ...