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

HoldAll

HoldAll
is an attribute which specifies that all arguments to a function are to be maintained in an unevaluated form.
  • You can use Evaluate to evaluate the arguments of a HoldAll function in a controlled way.
  • Even when a function has attribute HoldAll, Sequence objects that appear in its arguments are still by default flattened, Unevaluated wrappers are stripped, and upvalues associated with the arguments are used.
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Many functions with scoping behavior have the HoldAll attribute:
Plotting lists of functions will use separate styling for the different functions:
If the list structure is not manifest, no separate styling is provided:
Use Evaluate to make the list structure manifest:
Different vector-valued functions in a list will still get separate styling:
Use HoldAll and Unevaluated to suppress evaluation of symbols wherever it would occur:
Find the length of a symbol's name even if it has a value:
Implement your own control structure:
Hold is a container with the attribute HoldAll:
Functions that operate on symbols often need the HoldAll attribute:
Without the attribute, they would operate on the symbol's value:
Control structures such as Table protect their arguments from evaluation:
Otherwise, global values might interfere with their operation:
Use Evaluate to force evaluation of an argument of a HoldAll function:
Force evaluation of the right-hand side of a delayed definition:
Use Unevaluated to temporarily treat a function as if it had the attribute HoldAll:
Unevaluated inside a held expression is not removed:
This is the full form of the evaluation result:
This is the full form of the input, before evaluation:
Suppress the evaluation of the arguments of a pure function:
Sequence splicing still happens for HoldAll functions:
Use the container HoldComplete to suppress even such transformations:
The attribute that causes this behavior is HoldAllComplete:
Substitution works inside a held expression:
Insert into a held expression:
NHoldAll protects arguments from N, but evaluates them normally otherwise:
HoldPattern protects patterns from evaluation, but does not interfere with pattern matching:
New in 1