CompilerCallback
CompilerCallback["name"]
is a function that, if defined in a compiler environment, is automatically called by the Wolfram Compiler.
Details
- The following callbacks are supported with the specified types:
-
"OnFree" {t}->"Null" called on memory-managed objects with the type t when they are about to be freed "SerializeToExpression" {t}->"InertExpression" called to convert objects of type t to expressions when interfacing between compiled and interpreted code "DeserializeFromExpression" {"InertExpression"}->t called to convert expressions to objects of type t when interfacing between compiled and interpreted code "DeserializableFromExpressionQ" {"InertExpression","TypeSpecifier"::[t]}->"Boolean" called to check whether an expression is in a form that can be deserialized as an object with type t - CompilerCallback["OnFree"] can be defined to specify custom deconstructors for memory-managed types that require manual deconstruction.
- Expression serialization callbacks can be defined to specify how types are converted to and from expressions when interfacing between compiled and interpreted code.
Examples
open allclose allBasic Examples (1)
Scope (1)
CompilerCallback can be used to specify how compiled types are converted to and from expressions. Define a product type:
Define a callback function to convert myProduct objects into expressions of the form f[{f1},f2]:
Define a callback function to identify when an expression is in the correct form to be converted to a myProduct object:
Define a callback function to convert an expression to a myProduct object:
Compile a function that accepts and returns a myProduct object, converting it to and from an expression:
Expressions that do not have the correct form will not be converted:
Properties & Relations (1)
CompiledExpressionDeclaration automatically defines expression serialization callbacks. Declare a compiled expression type for expressions of the form f[_Real,_Integer]:
Compile a function that accepts and returns this type, converting it to and from an expression:
Expressions that do not have the correct form will not be converted:
Text
Wolfram Research (2022), CompilerCallback, Wolfram Language function, https://reference.wolfram.com/language/ref/CompilerCallback.html.
CMS
Wolfram Language. 2022. "CompilerCallback." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CompilerCallback.html.
APA
Wolfram Language. (2022). CompilerCallback. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CompilerCallback.html