is an attribute that 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.
Examplesopen allclose all
Basic Examples (1)
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:
Properties & Relations (13)
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:
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 functions with the attribute HoldAll:
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:
Wolfram Research (1988), HoldAll, Wolfram Language function, https://reference.wolfram.com/language/ref/HoldAll.html.
Wolfram Language. 1988. "HoldAll." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HoldAll.html.
Wolfram Language. (1988). HoldAll. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HoldAll.html