gives information about the enclosing compiled function.
CurrentCompiledFunctionData[prop]
gives the value of the property prop for the enclosing compiled function.
CurrentCompiledFunctionData
gives information about the enclosing compiled function.
CurrentCompiledFunctionData[prop]
gives the value of the property prop for the enclosing compiled function.
Details
- CurrentCompiledFunctionData is only available in compiled code.
- The name returned from a call to CurrentCompiledFunctionData will be that set by FunctionDeclaration.
- CurrentCompiledFunctionData["ReturnType"] is a useful way to access the return type of a function.
- A call to CurrentCompiledFunctionData returns a result of type "CompiledFunctionData".
- The result of a call to CurrentCompiledFunctionData contains the type of the enclosing function, and therefore it cannot be returned from a function.
- The following properties are supported:
-
"Type" the type of the enclosing function "ReturnType" the return type of the enclosing function
Examples
open all close allBasic Examples (2)
Compile and evaluate a function that prints out information about the current function:
comp = FunctionCompile[Function[Typed[arg, "Integer64"], Echo[CurrentCompiledFunctionData[]]; {arg}]];
comp[10]Print out the type of the function:
comp = FunctionCompile[Function[Typed[arg, "Integer64"], Echo[CurrentCompiledFunctionData["Type"]]; {arg}]];
comp[10]Print out the return type of the function:
comp = FunctionCompile[Function[Typed[arg, "Integer64"], Echo[CurrentCompiledFunctionData["ReturnType"]]; {arg}]];
comp[10]If CurrentCompiledFunctionData appears in a function with a name, this is included:
decl = FunctionDeclaration[DemoFunc, Typed[{"Integer64"} -> "PackedArray"::["Integer64", 1]]@Function[{arg}, Echo[CurrentCompiledFunctionData[]];{arg}]];comp = FunctionCompile[decl, Function[Typed[arg, "Integer64"], DemoFunc[arg]]];
comp[10]Scope (3)
CurrentCompiledFunctionData can only be used in compiled code:
CurrentCompiledFunctionData[]A function declaration that returns a zero of the return type:
decl = FunctionDeclaration[makeZero, Typed[ForAllType[e, {} -> e]]@Function[{}, TypeHint[0, CurrentCompiledFunctionData["ReturnType"]]]];comp = FunctionCompile[decl, Function[Typed[arg, "Integer64"], TypeHint[makeZero[], TypeOf[arg]]]];
Information[comp, "Type"]comp = FunctionCompile[decl, Function[Typed[arg, "Real64"], TypeHint[makeZero[], TypeOf[arg]]]];
Information[comp, "Type"]The result of CurrentCompiledFunctionData can be passed into a function that can extract information such as the name:
decls = {
FunctionDeclaration[printName, Typed[ForAllType[funTy, {"CompiledFunctionData"::[funTy]} -> "Null"]]@Function[{arg}, Print[arg["Name"]]]
]
,
FunctionDeclaration[functionName["MyFunction"],
Typed[{} -> "Null"]@
Function[{}, printName[CurrentCompiledFunctionData[]]]
]};This prints the name of the function in which CurrentCompiledFunctionData appears:
comp = FunctionCompile[decls, Function[{}, functionName["MyFunction"][]]];
comp[]Possible Issues (1)
The result of a call to CurrentCompiledFunctionData cannot be returned from a function:
FunctionCompile[Function[{}, CurrentCompiledFunctionData[]]]If CurrentCompiledFunctionData[] is cast to an "InertExpression", then compilation can succeed:
cf = FunctionCompile[Function[{}, Cast[CurrentCompiledFunctionData[], "InertExpression"]]][]When it is called, the resulting CompiledFunctionData object shows that the return type is an "InertExpression":
cf[]Tech Notes
Related Guides
History
Text
Wolfram Research (2025), CurrentCompiledFunctionData, Wolfram Language function, https://reference.wolfram.com/language/ref/CurrentCompiledFunctionData.html.
CMS
Wolfram Language. 2025. "CurrentCompiledFunctionData." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CurrentCompiledFunctionData.html.
APA
Wolfram Language. (2025). CurrentCompiledFunctionData. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CurrentCompiledFunctionData.html
BibTeX
@misc{reference.wolfram_2026_currentcompiledfunctiondata, author="Wolfram Research", title="{CurrentCompiledFunctionData}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/CurrentCompiledFunctionData.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_currentcompiledfunctiondata, organization={Wolfram Research}, title={CurrentCompiledFunctionData}, year={2025}, url={https://reference.wolfram.com/language/ref/CurrentCompiledFunctionData.html}, note=[Accessed: 13-June-2026]}