WOLFRAM

CompiledExpressionDeclaration
Copy to clipboard.
CompiledExpressionDeclaration

[Experimental]

Copy to clipboard.

represents a type for expressions of the form h[x1,x2,,xn], suitable for use in compiled code.

Copy to clipboard.

represents a type for expressions of the form h[x1,x2,,xn], with xi having the type ti.

Copy to clipboard.

names the declared type "name".

Copy to clipboard.
CompiledExpressionDeclaration[h"name"::[v1,v2,],{t1,t2,}]

represents a parameterized type with parameters labeled by v1,v2,.

Copy to clipboard.
CompiledExpressionDeclaration[h"name"::[v1,v2,],cond,{t1,t2,}]

asserts the condition cond on the type parameters.

Copy to clipboard.

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 all

Basic 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:

Compile a function which instantiates and returns an object with the new type:

Out[2]=2
Out[3]=3

Represent a declaration of a type representing expressions with the head foo and length 2 and that internally stores the data in an expression:

Compile a function that takes foo as an argument and returns it unchanged:

Out[2]=2

The function accepts expressions that have the specified structure:

Out[3]=3

But rejects expressions that do not have the specified structure:

Out[4]=4

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:

Compile a function that returns an object with that type:

Out[2]=2
Out[3]=3

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:

Compile a function that returns an object with that type:

Out[2]=2
Out[3]=3

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:

Out[4]=4
Out[5]=5
Wolfram Research (2022), CompiledExpressionDeclaration, Wolfram Language function, https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html.
Copy to clipboard.
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.

Copy to clipboard.
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.

Copy to clipboard.
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

Copy to clipboard.
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 ]}

Copy to clipboard.
@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 ]}

Copy to clipboard.
@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 ]}