Clojure: Reader Forms
This page is WORK IN PROGRESS.
- symbol
- literals
- lists
- vectors
- maps
- sets
- deftype, defrecord, constructor calls
symbols begin with a non-numeric character. Can contain 0 to 9, a to z, * + ! - _ ?
/ is used once to separate namespaces.
. has special meaning — it can be used one or more times in the middle of a symbol to designate a fully-qualified class name, for example, java.util.BitSet
, or in namespace names.
Symbols beginning or ending with . are reserved by Clojure.
Symbols containing / or . are said to be 'qualified'.
Symbols beginning or ending with : are reserved by Clojure. A symbol can contain one or more non-repeating ':'s.
- forms
-
lisps refer to its syntax units as “forms”. For example,
(+ 3 4)
is a form. Anything that returnsa value is a form. - literal
-
a form that eval to itself. String
"…"
, number, character\b
, are literals.true
,false
,nil
, are also literals. - symbol
-
Symbols are like other lang's identifiers, except that lisp symbol is a identity that can be held unevaluated and be manipulated in unevaluated state. For example, if x has value of 3 (
def x 3
), then'x
eval to the symbol “x” itself, not its value. Macros are possible because of this. (You can think of “symbol” as a string, a label, a identifier.) - expressions
-
a form made of other forms. Typically they are enclosed by brackets. For example, list
(…)
, vector[…]
, map{…}
. Normally, a form is a function in the form of a list(head …)
. The first element is the symbol of the function. The rest are arguments, and are evaluated in order. - special form
-
a form that has different evaluation order or special in some other way. For example,
if
is a special form. http://clojure.org/special_forms