Clojure programs are composed of expressions. Every form not handled specially by a special form or macro is considered by the compiler to be an expression, which is evaluated to yield a value. [1]
An expression is a form which will be (or can be) evaluated in the final program. [2]
For instance, consider the form (fn [x] (inc x))
. It is a list of three elements: the special form fn
, the vector [x]
, and the list (inc x)
. All of those elements are forms, but only the last is an expression, because it is "intended" for evaluation; the first two forms are shuffled around by the macroexpander but never evaluated. The outermost form (fn [x] (inc x))
is itself an expression as well.
This seems to be an interesting distinction, but it does mean it is context-sensitive: [x]
is always a form, and may or may not be an expression depending on context. For instance, as in the example above ((fn [x] (inc x))
), [x]
is a form not an expression because it's handled specially by the special form fn
;