What are special forms?
In Common Lisp, a special form is a Lisp expression that looks like a function call, i.e., has the form (function-name ...), but is, in fact, treated specially by the Lisp interpreter.
Function calls always work the same way:
- All the arguments, if any, are evaluated.
- The values of the arguments, and only the values are passed to the function, through its formal parameters.
Special forms, on the other hand, have no such regular pattern of behavior. Here are some examples of special forms that violate the above rules:
ais not evaluated.
(if (> x y) a b)
- The first argument is evaluated, but, depending on whether
yis larger, either the second or third argument will not be evaluated.
(let ((x 10)) (* x x))
- Part of the first argument is evaluated, and part is not.
letis able to refer to and modify
xitself, not just the value of
(defun foo (x) (+ x 1))
- None of the arguments to
defunare evaluated. In fact, neither the function name,
foo, nor the parameter list,
(x), should ever be evaluated.
Common Lisp comes with a predefined set of special functions,
or, and so on.
You can't define your own special functions, but you can do something almost as good, using macros.