CompiledExpressionDeclarationCopy to clipboard.
✖
CompiledExpressionDeclaration
represents a type for expressions of the form h[x1,x2,…,xn], suitable for use in compiled code.
represents a type for expressions of the form h[x1,x2,…,xn], with xi having the type ti.
represents a parameterized type with parameters labeled by v1,v2,….
asserts the condition cond on the type parameters.
represents a type for any expression expr on which the compilable function test returns True.
Details
- CompiledExpressionDeclaration is a symbolic representation of a declaration and does not evaluate on its own.
- CompiledExpressionDeclaration can be used inside of CompilerEnvironmentAppendTo and the first argument of functions like FunctionCompile.
- When no explicit type name is provided, SymbolName[h] is used.
- When argument types are specified, compiled expressions are internally stored as an efficient product type.
- When argument types are specified, CompiledExpressionDeclaration automatically defines functions including constructors Part and Head.
- When argument types are not specified, compiled expressions are internally stored with "InertExpression".
- When argument types are not specified, test[expr,ty] is used to check whether a given expression expr matches the compiled expression type ty.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Represent a declaration of a type representing expressions of the form foo[_Integer,_Real] but that internally stores the data in a product type:
https://wolfram.com/xid/0bzp656wem1swb8nq-ylqbjf
Compile a function which instantiates and returns an object with the new type:
https://wolfram.com/xid/0bzp656wem1swb8nq-m0ky5j
https://wolfram.com/xid/0bzp656wem1swb8nq-qgtxlr
Represent a declaration of a type representing expressions with the head foo and length 2 and that internally stores the data in an expression:
https://wolfram.com/xid/0bzp656wem1swb8nq-lgpu5k
Compile a function that takes foo as an argument and returns it unchanged:
https://wolfram.com/xid/0bzp656wem1swb8nq-48acv3
The function accepts expressions that have the specified structure:
https://wolfram.com/xid/0bzp656wem1swb8nq-hmuasn
But rejects expressions that do not have the specified structure:
https://wolfram.com/xid/0bzp656wem1swb8nq-8kpgv6
Scope (2)Survey of the scope of standard use cases
A declaration of a type representing expressions with head foo and that takes any number in its first argument and a Boolean in its second argument:
https://wolfram.com/xid/0bzp656wem1swb8nq-oqmzl4
Compile a function that returns an object with that type:
https://wolfram.com/xid/0bzp656wem1swb8nq-361qgj
https://wolfram.com/xid/0bzp656wem1swb8nq-dd9qom
Note that the return type of the function is parameterized by the type of number that the foo takes in its first argument.
A declaration of a type representing expressions with head foo and that takes any two arguments:
https://wolfram.com/xid/0bzp656wem1swb8nq-1bvmkg
Compile a function that returns an object with that type:
https://wolfram.com/xid/0bzp656wem1swb8nq-bx7syt
https://wolfram.com/xid/0bzp656wem1swb8nq-2vbibe
Note that the return type of the function is parameterized by the two argument types. This is equivalent to declaring a compiled expression that has unrestricted type variables in both arguments:
https://wolfram.com/xid/0bzp656wem1swb8nq-uk9mmp
https://wolfram.com/xid/0bzp656wem1swb8nq-ow2hzr
Wolfram Research (2022), CompiledExpressionDeclaration, Wolfram Language function, https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html.
Text
Wolfram Research (2022), CompiledExpressionDeclaration, Wolfram Language function, https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html.
Wolfram Research (2022), CompiledExpressionDeclaration, Wolfram Language function, https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html.
CMS
Wolfram Language. 2022. "CompiledExpressionDeclaration." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html.
Wolfram Language. 2022. "CompiledExpressionDeclaration." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html.
APA
Wolfram Language. (2022). CompiledExpressionDeclaration. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html
Wolfram Language. (2022). CompiledExpressionDeclaration. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html
BibTeX
@misc{reference.wolfram_2024_compiledexpressiondeclaration, author="Wolfram Research", title="{CompiledExpressionDeclaration}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html}", note=[Accessed: 10-January-2025
]}
BibLaTeX
@online{reference.wolfram_2024_compiledexpressiondeclaration, organization={Wolfram Research}, title={CompiledExpressionDeclaration}, year={2022}, url={https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html}, note=[Accessed: 10-January-2025
]}