Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > Expressions > Evaluation Control > HoldAll >

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
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF