System.ConstructorOf - Manhunter07/MFL GitHub Wiki

Declaration

function ConstructorOf(T: type): function = \built-in\

Description

The ConstructorOf function in the System package returns the constructor of a given type passed by reference. The argument for the Obj parameter must be a type reference. If the type has a declared or implicit constructor, it is returned as reference. If not, the function returns Nil.

Example

See also: System.Split

A type without a constructor strictly returns Nil when passed:

type PersonName = record(First, Last, Title)
ConstructorOf(@PersonName) \returns Nil\

If we then however declare a constructor, it will be returned as a function-reference:

constructor PersonName(FullName: String) = Split(' ', FullName)
ConstructorOf(@PersonName) \returns a reference to the constructor above\

See also