Bindings Are Things Too

Surprisingly, the bindings between symbols and values, the things created by def, are also ordinary values. When you evaluate a def, Clojure creates a var, a thing that represents the binding between a symbol and a value. As illustrated in the figure, you can think of vars as having two slots: there’s a place for the symbol (maybe author) and a place for the value (perhaps "Austen").

images/vars.png

In a lovely bit of introspection, you can also get at a var with the proper incantation, this time a # followed by a :

 (​def​ author ​"Austen"​) ​; Make a var.
 
 #​'author​ ​; Get at the var for author -> "Austen".

Like any other Clojure ...

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.