"InertExpression" (Compiled Type)
"InertExpression"
represents an inert expression that is not automatically evaluated.
Details
- "InertExpression" can be used in Typed and related constructs to specify a type.
- "InertExpression" objects are automatically memory managed.
- "InertExpression" objects are internally represented identically to Wolfram Language expressions.
- "InertExpression" objects are inert and will only evaluate on calls to InertEvaluate.
Constructors
- InertExpression[expr] constructs an inert expression object from the constant expr.
- head[arg1,arg2,…] constructs an inert expression head[arg1,arg2,…] where head is an inert expression and arg1 etc... are converted into inert expressions.
- Construct[head,arg1,arg2,…] constructs an inert expression head[arg1,arg2,…] where head is an inert expression and arg1 etc... are converted into inert expressions.
Properties
- InertEvaluate evaluates an inert expression.
Conversions
- Inert expressions are automatically converted to and from expressions when passed between evaluated and compiled code. »
Expressions
Examples
open all close allBasic Examples (2)
Compile a program that returns an inert expression:
cf = FunctionCompile[Function[{}, InertExpression[foo]]]cf[]Inert expressions can be manipulated without being evaluated:
cf = FunctionCompile[Function[{}, Length[InertExpression[2 + 2]]]]cf[]Scope (4)
Inert expressions are automatically converted to expressions and evaluated when returned from compiled code:
cf = FunctionCompile[Function[{}, InertExpression[Echo["bam!"];2 + 2]]]cf[]Construct an inert expression:
cf = FunctionCompile[Function[{Typed[head, "InertExpression"]},
head[1, 2, 4]]]cf[f]Construct an inert expression, wrapping it in Hold before returning from compiled code:
cf = FunctionCompile[Function[{},
InertExpression[Hold][InertExpression[Total][{1, 2, 3}]
]]]cf[]The command Construct can also be used:
cf = FunctionCompile[Function[{},
Construct[InertExpression[Hold], Construct[InertExpression[Total], {1, 2, 3}]]
]]cf[]Properties & Relations (1)
Inert expressions can be evaluated with InertEvaluate:
cf = FunctionCompile[Function[{}, InertEvaluate[InertExpression[2 + 2]]]]See Also
Tech Notes
Related Guides
History
Introduced in 2022 (13.1)