Basic Special Forms
So far, we have been writing code that complies with the simplest rules of evaluating Clojure code, but there are some behaviors that cannot simply be encoded with normal functions. For example, arguments that have been passed to a function will always be resolved or evaluated, but what if we do not want to evaluate all the operands of an operator? That is when special forms come into play. They can have different evaluation rules for functions when the source code is read by Clojure. For example, the special form if
, may not evaluate one of its arguments, depending on the result of the first argument.
There are a few other special forms that we will go through in this section:
when
, which can be used when we are only interested in the case of a condition being truthy (a value is truthy when considered true in the context of a Boolean expression).do
, which can be used to execute a series of expressions and return the value of the last expression...