CompiledExpressionDeclaration

CompiledExpressionDeclaration[h,n]

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

CompiledExpressionDeclaration[h,{t1,t2,}]

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

CompiledExpressionDeclaration[h"name",]

names the declared type "name".

CompiledExpressionDeclaration[h"name"::[v1,v2,],{t1,t2,}]

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

CompiledExpressionDeclaration[h"name"::[v1,v2,],cond,{t1,t2,}]

asserts the condition cond on the type parameters.

CompiledExpressionDeclaration[,test]

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)

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:

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:

The function accepts expressions that have the specified structure:

But rejects expressions that do not have the specified structure:

Scope  (2)

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:

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:

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:

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.

CMS

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

BibTeX

@misc{reference.wolfram_2022_compiledexpressiondeclaration, author="Wolfram Research", title="{CompiledExpressionDeclaration}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html}", note=[Accessed: 12-August-2022 ]}

BibLaTeX

@online{reference.wolfram_2022_compiledexpressiondeclaration, organization={Wolfram Research}, title={CompiledExpressionDeclaration}, year={2022}, url={https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html}, note=[Accessed: 12-August-2022 ]}