A type alias can give a new name to an existing type, whether that type is declared in the same project, or elsewhere.
Type aliases can serve many purposes. They can provide a short-hand for an otherwise more complex to write type (such as Array or a Tuple with a specific configuration) or they can distinguish between different use cases of the same base type (such as declaring different, incompatible aliases to
Double refer to different units of measure.
Type aliases can be declared by simply following the equal sign with the name of another type, optionally preceded by a Visibility Level.
type Number = public Integer; // "Number" now has the same meaning as "Integer"
Incompatible Type Aliases
A type alias can be marked to be deliberately incompatible with the original type (and other aliases to the same type) by applying the
type Type Modifier:
type Celsius = type Double; Farenheit = type Double; var BoilingTemp: Celsius = 100.0; var OvenTemperature: Fahrenheit := BoilingTemp; // this assignment will fail with an error.
operator Explicit(C: Celsius): Fahrenheit; begin result := (C * 9.0/5.0) + 32.0 end; ... var OvenTemperature: Fahrenheit := Fahrenheit(BoilingTemp);