This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / The Mathematica Book / Mathematica Reference Guide / Evaluation /

A.4.2 Non-Standard Argument Evaluation

There are a number of built-in Mathematica functions that evaluate their arguments in special ways. The control structure While is an example. The symbol While has the attribute HoldAll. As a result, the arguments of While are not evaluated as part of the standard evaluation process. Instead, the internal code for While evaluates the arguments in a special way. In the case of While, the code evaluates the arguments repeatedly, so as to implement a loop.

Built-in functions that evaluate their arguments in special ways.

Logical Operations

In an expression of the form &&&& the are evaluated in order. As soon as any is found to be False, evaluation is stopped, and the result False is returned. This means that you can use the to represent different "branches" in a program, with a particular branch being evaluated only if certain conditions are met.

The Or function works much like And; it returns True as soon as it finds any argument that is True. Xor, on the other hand, always evaluates all its arguments.

Iteration Functions

An iteration function such as Do[f, i, imin, imax] is evaluated as follows:

FilledSmallSquare The iteration specification is evaluated. If it is not found to be of the form i, imin, imax, the evaluation stops.

FilledSmallSquare The value of the iteration variable i is made local, effectively using Block.

FilledSmallSquare imin and imax are used to determine the sequence of values to be assigned to the iteration variable i.

FilledSmallSquare The iteration variable is successively set to each value, and f is evaluated in each case.

FilledSmallSquare The local values assigned to i are cleared.

If there are several iteration variables, the same procedure is followed for each variable in turn, for every value of all the preceding variables.

Unless otherwise specified, f is not evaluated until a specific value has been assigned to i, and is then evaluated for each value of i chosen. You can use Evaluate[f] to make f be evaluated immediately, rather than only after a specific value has been assigned to i.


The left-hand sides of assignments are only partially evaluated.

FilledSmallSquare If the left-hand side is a symbol, no evaluation is performed.

FilledSmallSquare If the left-hand side is a function without hold attributes, the arguments of the function are evaluated, but the function itself is not evaluated.

The right-hand side is evaluated for immediate (=), but not for delayed (:=), assignments.

Any subexpression of the form HoldPattern[expr] that appears on the left-hand side of an assignment is not evaluated, but is replaced by the unevaluated form of expr before the assignment is done.