CompiledExpressionDeclaration[h,n]
表示形为 h[x1,x2,…,xn] 的表达式的类型,适合在编译代码中使用.
CompiledExpressionDeclaration[h,{t1,t2,…}]
表示形为 h[x1,x2,…,xn] 的表达式的类型,其中,xi 的类型为 ti.
CompiledExpressionDeclaration[h"name",…]
命名已声明的类型 "name".
CompiledExpressionDeclaration[h"name"::[v1,v2,…],{t1,t2,…}]
表示参数化类型,其中,参数的标签为 v1,v2,….
CompiledExpressionDeclaration[h"name"::[v1,v2,…],cond,{t1,t2,…}]
断言类型参数的条件 cond.
CompiledExpressionDeclaration[…,test]
表示任意表达式 expr 的类型,对其应用可编译函数 test 后返回 True.
CompiledExpressionDeclaration
CompiledExpressionDeclaration[h,n]
表示形为 h[x1,x2,…,xn] 的表达式的类型,适合在编译代码中使用.
CompiledExpressionDeclaration[h,{t1,t2,…}]
表示形为 h[x1,x2,…,xn] 的表达式的类型,其中,xi 的类型为 ti.
CompiledExpressionDeclaration[h"name",…]
命名已声明的类型 "name".
CompiledExpressionDeclaration[h"name"::[v1,v2,…],{t1,t2,…}]
表示参数化类型,其中,参数的标签为 v1,v2,….
CompiledExpressionDeclaration[h"name"::[v1,v2,…],cond,{t1,t2,…}]
断言类型参数的条件 cond.
CompiledExpressionDeclaration[…,test]
表示任意表达式 expr 的类型,对其应用可编译函数 test 后返回 True.
更多信息
- CompiledExpressionDeclaration 是声明的符号表示,不进行计算.
- CompiledExpressionDeclaration 可被用在 CompilerEnvironmentAppendTo 中或是如 FunctionCompile 这样的函数的第一个参数.
- 没有提供明确的类型名称的情况下,使用 SymbolName[h].
- 在参数类型被指定的情况下,编译表达式在内部被存储为有效的 product 类型.
- 在参数类型被指定的情况下,CompiledExpressionDeclaration 自动定义函数,包括 constructor Part 和 Head.
- 没有指定参数类型的情况下,编译表达式在内部被存储为 "InertExpression".
- 没有指定参数类型的情况下,用 test[expr,ty] 来查看一个给定表达式 expr 是否与已编译表达式类型 ty 匹配.
范例
打开所有单元 关闭所有单元基本范例 (2)
表示一种类型的声明,该类型表示形为 foo[_Integer,_Real] 的表达式,但在内部将数据存储为 product 类型:
dec = CompiledExpressionDeclaration[foo, {"Integer64", "Real64"}];cf = FunctionCompile[dec, Function[{}, foo[3, 5.6]]]cf[]表示一个类型的声明,该类型表示标头为 foo 和长度 2 的表达式,并且在内部将数据存储在表达式中:
dec = CompiledExpressionDeclaration[foo, Function[{expr, ty}, Length[expr] === 2]];cf = FunctionCompile[dec, Function[Typed[arg, "foo"], arg]]cf[foo[1, 2]]cf[bar[1, 2, 3]]范围 (2)
一个表示表达式的类型的声明,其标头为 foo,它的第一个参数可以是任意数字,第二个参数是布尔值:
dec = CompiledExpressionDeclaration[foo -> "foo"::[n], n∈"Numbers", {n, "Boolean"}];cf = FunctionCompile[dec, Function[{}, foo[3.6, True]]]cf[]注意,函数的返回类型由 foo 的第一个参数接受的数字的类型参数化.
表示标头为 foo 的表达式的类型的声明,它接受任意两个参数:
dec = CompiledExpressionDeclaration[foo, 2];cf = FunctionCompile[dec, Function[{}, foo[3, True]]]cf[]注意,函数的返回类型两个参数的类型参数化. 这相当于声明两个参数都含有不受限制的类型变量的编译表达式:
cf = FunctionCompile[{
CompiledExpressionDeclaration[foo -> "foo"::[t1, t2], {t1, t2}]
},
Function[{}, foo[3, True]]]cf[]技术笔记
文本
Wolfram Research (2022),CompiledExpressionDeclaration,Wolfram 语言函数,https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html.
CMS
Wolfram 语言. 2022. "CompiledExpressionDeclaration." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html.
APA
Wolfram 语言. (2022). CompiledExpressionDeclaration. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html 年
BibTeX
@misc{reference.wolfram_2026_compiledexpressiondeclaration, author="Wolfram Research", title="{CompiledExpressionDeclaration}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html}", note=[Accessed: 19-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_compiledexpressiondeclaration, organization={Wolfram Research}, title={CompiledExpressionDeclaration}, year={2022}, url={https://reference.wolfram.com/language/ref/CompiledExpressionDeclaration.html}, note=[Accessed: 19-June-2026]}