Previous: , Up: Iteration Forms   [Contents][Index]


4.2 Special-Clause Operators

Special-clause operators are auxiliary operators in the sense that they are heads of auxiliary forms that are only syntactically valid in certain forms. In the case of special-clause operators, the auxiliary forms they head are valid in the for-clause and body positions of the iteration forms. Beside special-clause operators, :do-in is an auxiliary operator heading a sequence form, whose specification can be found in later chapters.

Below, “the iteration” can be an empty iteration when no iteration clause follows the special clauses, whose body expanded so far are bodys. Moreover, the inner iteration does not affect the outer iteration when nesting occurs, unless the wording “the whole iteration” is used.

Special clauses are sequentially processed, such that the body produced by the expander of a special clause is fed into the expander of another special clause to its left. Nonetheless, :break and :final clauses are specially expanded since they involve non-local transformation in order to terminate the whole iteration. As a result, they cannot be implemented by define-for-special-clause.

Auxiliary Operator: :break [guard…]

This special-clause operator immediately terminates the whole iteration when (and [guard…]) is true before the iteration.

Auxiliary Operator: :final [guard…]

This special-clause operator terminates the whole iteration after one more iteration when (and [guard…]) is true before the iteration.

Auxiliary Operator: :if [guard…]

This special-clause operator produces the following body:

(when (and [guard…])
  [body…])
Auxiliary Operator: :if-not [guard…]

This special-clause operator produces the following body:

(unless (and [guard…])
  [body…])
Auxiliary Operator: :let [binding…]

This special-clause operator produces the following body:

(pcase-let ([binding…])
  [body…])
Auxiliary Operator: :let* [binding…]

This special-clause operator produces the following body:

(pcase-let* ([binding…])
  [body…])
Auxiliary Operator: :if-let [binding…]

This special-clause operator produces the following body:

(when-let ([binding…])
  [body…])
Auxiliary Operator: :if-let* [binding…]

This special-clause operator produces the following body:

(when-let* ([binding…])
  [body…])
Auxiliary Operator: :pcase expression [:exhaustive] [pattern…]

This special-clause operator produces the following body where pcase is pcase (see (elisp)Pattern-Matching Conditional) when :exhaustive is omitted, otherwise it is pcase-exhaustive:

(pcase expression
  ((and [pattern…])
   [body…]))
Auxiliary Operator: :pcase-not expression [:as as] [pattern…]

This special-clause operator produces the following body where as is an identifier that defaults to _ when omitted:

(pcase expression
  ((and [pattern…])
   nil)
  (as
   [body…]))
Auxiliary Operator: :do [expression…]

This special-clause operator prepends expressions to the body.


Previous: Iteration Macros, Up: Iteration Forms   [Contents][Index]