is an attribute which specifies that all but the first argument to a function are to be maintained in an unevaluated form.
HoldRest
is an attribute which specifies that all but the first argument to a function are to be maintained in an unevaluated form.
Examples
open all close allBasic Examples (1)
Give the function f the attribute HoldAll:
SetAttributes[f, HoldRest]As a result, the second and subsequent arguments are not evaluated prior to entering the (in this case nonexistent) function body:
f[1 + 1, 2 + 2, 3 + 3]Compare with a function g that has no attributes:
g[1 + 1, 2 + 2, 3 + 3]Scope (2)
The first argument of If is always evaluated, but the others are only evaluated if that corresponding branch is entered:
If[a || b || False, 1 + 1, 2 + 2]This is because If has the attribute HoldRest:
Attributes[If]Give the function inout the attribute HoldRest:
SetAttributes[inout, HoldRest]Define a function of two arguments that returns them wrapped in Hold as well as the second without wrapping:
inout[tag_, in_] := {Hold[tag], Hold[in], in}The first argument is evaluated prior to entering the function body, while the second is evaluated inside the function body:
inout[1 - 1, 1 + 1]Applications (1)
Properties & Relations (4)
Use Evaluate to force evaluation of an argument of a HoldRest function:
SetAttributes[h, HoldRest]h[1 + 1, Evaluate[2 + 2], 3 + 3]Suppress the evaluation of all but the first argument of a pure function:
Function[{e, f, g}, Hold[e, f, g], {HoldRest}][1 + 2, 2 + 3, 3 + 4]Sequence splitting still happens for HoldRest functions:
SetAttributes[f, HoldRest]f[1 + 1, Sequence[1 + 1, 2 + 2]]NHoldRest protects arguments from N, but evaluates them normally otherwise:
Attributes[Subscript]N[Subscript[a, 1]]Subscript[a, 1 + 2]Tech Notes
Related Guides
Related Workflows
- Substitute Values of Variables in Functions That Hold Their Arguments
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), HoldRest, Wolfram Language function, https://reference.wolfram.com/language/ref/HoldRest.html.
CMS
Wolfram Language. 1988. "HoldRest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HoldRest.html.
APA
Wolfram Language. (1988). HoldRest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HoldRest.html
BibTeX
@misc{reference.wolfram_2026_holdrest, author="Wolfram Research", title="{HoldRest}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/HoldRest.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_holdrest, organization={Wolfram Research}, title={HoldRest}, year={1988}, url={https://reference.wolfram.com/language/ref/HoldRest.html}, note=[Accessed: 13-June-2026]}