Elements

Ken Pu
Tuesday, May 1, 2018

Clojure is very different from imperative languages such as Java / C / Go. A Clojure program is represented entirely as a data structure.

Elements of Clojure

Let’s first look at how Clojure represents data in its source file.

Data in Clojure source file

Literals: numbers, strings, characters

Lists

Vectors

Hashmaps

{ <key> <value> <key> <value> ... }

Symbols

My personal favourite feature of Clojure is amazingly generous naming rule.

The following are all valid symbol names:

  • get-record-from-id
  • id->record
  • x, x', x''
  • <--*-->: Yes, you can have a symbol like this. It’s crazy.
  • : Yes, this can be valid Clojure code: (∮ x' dx)

Keywords

:age
:runtime-port

Binding & Scoping

Binding

Don't forget that data can be many things include other symbols.

Scopes

Nested Scopes

comments powered by Disqus