-
See Also
- InertEvaluate
- Construct
- KernelFunction
- KernelEvaluate
- Hold
- Inactive
-
- Compiled Types
- InertExpression
-
-
See Also
- InertEvaluate
- Construct
- KernelFunction
- KernelEvaluate
- Hold
- Inactive
-
- Compiled Types
- InertExpression
-
See Also
InertExpression[expr]
creates an inert expression in compiled code.
InertExpression[head][e1,e2,…]
creates an inert expression with head and arguments ei.
InertExpression
InertExpression[expr]
creates an inert expression in compiled code.
InertExpression[head][e1,e2,…]
creates an inert expression with head and arguments ei.
Details
- InertExpression is only available in compiled code.
- expr must be a constant value and must not contain any references to compiler variables. »
- InertExpression[expr] returns an object with the type "InertExpression".
- "InertExpression" objects returned by InertExpression are inert and will only evaluate on calls to InertEvaluate. »
- In InertExpression[head][e1,e2,…], the ei can be general compiler elements that are computed with compiled code and then converted into inert expressions.
Examples
open all close allBasic Examples (3)
Compile a program that returns an expression:
cf = FunctionCompile[Function[{}, InertExpression[foo]]]cf[]Compile a program that uses InertExpression as a head to construct a new expression:
cf = FunctionCompile[Function[{Typed[arg, "InertExpression"]}, InertExpression[f][arg]]]cf[x]Compile a program that uses InertExpression as a head to construct a new expression with an element converted from an integer:
cf = FunctionCompile[Function[{Typed[arg, "Integer64"]}, InertExpression[f][arg]]]cf[10]Scope (5)
Inert expressions can be manipulated without being evaluated:
cf = FunctionCompile[Function[{}, Length[InertExpression[2 + 2]]]]cf[]Construct an inert expression, wrapping it in Hold before returning from compiled code:
cf = FunctionCompile[Function[{},
InertExpression[Hold][InertExpression[Total][InertExpression[{1, 2, 3}]]]
]]cf[]By default, inert expressions are not evaluated:
cf1 = FunctionCompile[Function[{},
InertExpression[Echo]["foo"];
1
]]cf1[]InertEvaluate can be used to request evaluation:
cf2 = FunctionCompile[Function[{},
InertEvaluate[InertExpression[Echo]["foo"]];
2
]]cf2[]Inert expressions are automatically converted to expressions and evaluated when returned from compiled code:
cf = FunctionCompile[Function[{}, InertExpression[Echo["bam!"];2 + 2]]]cf[]Inert expressions do not evaluate:
cf = FunctionCompile[Function[{}, InertExpression[Hold[Echo["result"]]]]]cf[]When inert expressions are constructed from non-inert arguments, the latter will evaluate:
cf = FunctionCompile[Function[{}, InertExpression[Hold][Echo["result"]]]]cf[]Properties & Relations (1)
Inert expressions can be evaluated with InertEvaluate:
cf = FunctionCompile[Function[{}, InertEvaluate[InertExpression[2 + 2]]]]Possible Issues (3)
InertExpression only works in compiled code:
InertExpression[2 + 2]Inert expressions may evaluate when returned from compiled code:
cf = FunctionCompile[Function[{}, InertExpression[2 + 2]]]cf[]Wrap inert expressions in Hold before returning to prevent them from being evaluated:
cf = FunctionCompile[Function[{},
InertExpression[Hold][InertExpression[2 + 2]]
]]cf[]InertExpression does not take compiler variables into account:
cf = FunctionCompile[Function[{},
With[{a = 12}, InertExpression[f[a]]]
]]cf[]The compiler variable can be passed as an argument and not inside the InertExpression wrapper:
cf = FunctionCompile[Function[{},
With[{a = 12}, InertExpression[f][a]]
]]cf[]See Also
InertEvaluate Construct KernelFunction KernelEvaluate Hold Inactive
Compiled Types: InertExpression
Text
Wolfram Research (2022), InertExpression, Wolfram Language function, https://reference.wolfram.com/language/ref/InertExpression.html (updated 2025).
CMS
Wolfram Language. 2022. "InertExpression." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/InertExpression.html.
APA
Wolfram Language. (2022). InertExpression. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/InertExpression.html
BibTeX
@misc{reference.wolfram_2026_inertexpression, author="Wolfram Research", title="{InertExpression}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/InertExpression.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_inertexpression, organization={Wolfram Research}, title={InertExpression}, year={2025}, url={https://reference.wolfram.com/language/ref/InertExpression.html}, note=[Accessed: 12-June-2026]}