@node Control Structures
@chapter Control Structures
@cindex special forms for control structures
+@cindex forms for control structures
@cindex control structures
A Lisp program consists of a set of @dfn{expressions}, or
@section Sequencing
@cindex sequencing
@cindex sequential execution
+@cindex forms for sequential execution
Evaluating forms in the order they appear is the most common way
control passes from one form to another. In some contexts, such as in a
@node Conditionals
@section Conditionals
@cindex conditional evaluation
+@cindex forms, conditional
Conditional control structures choose among alternatives. Emacs Lisp
has five conditional forms: @code{if}, which is much the same as in
@section Iteration
@cindex iteration
@cindex recursion
+@cindex forms, iteration
Iteration means executing part of a program repetitively. For
example, you might want to repeat some computation once for each element
@node Catch and Throw
@subsection Explicit Nonlocal Exits: @code{catch} and @code{throw}
+@cindex forms for nonlocal exits
Most control constructs affect only the flow of control within the
construct itself. The function @code{throw} is the exception to this
@subsubsection Writing Code to Handle Errors
@cindex error handler
@cindex handling errors
+@cindex forms for handling errors
The usual effect of signaling an error is to terminate the command
that is running and return immediately to the Emacs editor command loop.
@node Cleanups
@subsection Cleaning Up from Nonlocal Exits
@cindex nonlocal exits, cleaning up
+@cindex forms for cleanup
The @code{unwind-protect} construct is essential whenever you
temporarily put a data structure in an inconsistent state; it permits
@cindex vector evaluation
@cindex literal evaluation
@cindex self-evaluating form
+@cindex form, self-evaluating
A @dfn{self-evaluating form} is any form that is not a list or
symbol. Self-evaluating forms evaluate to themselves: the result of
@node Symbol Forms
@subsection Symbol Forms
@cindex symbol evaluation
+@cindex symbol forms
+@cindex forms, symbol
When a symbol is evaluated, it is treated as a variable. The result
is the variable's value, if it has one. If the symbol has no value as
@node Classifying Lists
@subsection Classification of List Forms
@cindex list form evaluation
+@cindex forms, list
A form that is a nonempty list is either a function call, a macro
call, or a special form, according to its first element. These three
@subsection Evaluation of Function Forms
@cindex function form evaluation
@cindex function call
+@cindex forms, function call
If the first element of a list being evaluated is a Lisp function
object, byte-code object or primitive function object, then that list is
@node Macro Forms
@subsection Lisp Macro Evaluation
@cindex macro call evaluation
+@cindex forms, macro call
If the first element of a list being evaluated is a macro object, then
the list is a @dfn{macro call}. When a macro call is evaluated, the
@node Special Forms
@subsection Special Forms
@cindex special forms
+@cindex forms, special
@cindex evaluation of special forms
A @dfn{special form} is a primitive function specially marked so that
@node Quoting
@section Quoting
+@cindex forms, quote
The special form @code{quote} returns its single argument, as written,
without evaluating it. This provides a way to include constant symbols
@cindex backquote (list substitution)
@cindex ` (list substitution)
@findex `
+@cindex forms, backquote
@dfn{Backquote constructs} allow you to quote a list, but
selectively evaluate elements of that list. In the simplest case, it