CreateTypeInstance

CreateTypeInstance[type,arg1,arg2,]

creates an instance of a type in compiled code.

CreateTypeInstance[productType,field1x1,field2x2,|>]

creates an instance of a product type and initializes its fields.

Details

  • The arguments in CreateTypeInstance[type,arg1,arg2,] can vary from type to type and are often documented with the type itself.
  • For many types, CreateTypeInstance[type,arg] creates a copy of arg if arg is an instance of type.
  • Some types that can be instantiated with CreateTypeInstance are not automatically memory managed and must be manually freed with DeleteObject.

Examples

open allclose all

Basic Examples  (2)

Compile a function that creates a "Managed"::["CArray"::["MachineInteger"]] object with length 5:

Create a product type declaration for "myProd":

Compile a function that instantiates "myProd":

Scope  (1)

Custom usages of CreateTypeInstance can be declared with FunctionDeclaration:

Compile a function that uses the custom constructor for the type:

Wolfram Research (2022), CreateTypeInstance, Wolfram Language function, https://reference.wolfram.com/language/ref/CreateTypeInstance.html.

Text

Wolfram Research (2022), CreateTypeInstance, Wolfram Language function, https://reference.wolfram.com/language/ref/CreateTypeInstance.html.

CMS

Wolfram Language. 2022. "CreateTypeInstance." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CreateTypeInstance.html.

APA

Wolfram Language. (2022). CreateTypeInstance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CreateTypeInstance.html

BibTeX

@misc{reference.wolfram_2023_createtypeinstance, author="Wolfram Research", title="{CreateTypeInstance}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/CreateTypeInstance.html}", note=[Accessed: 18-April-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_createtypeinstance, organization={Wolfram Research}, title={CreateTypeInstance}, year={2022}, url={https://reference.wolfram.com/language/ref/CreateTypeInstance.html}, note=[Accessed: 18-April-2024 ]}