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.

  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:

  Celsius = type Double;
  Farenheit = type Double;
var BoilingTemp: Celsius = 100.0;

var OvenTemperature: Fahrenheit := BoilingTemp; // this assignment will fail with an error.

You could even provide Custom Operators for the new incompatible types (as a global, or via an Extension that could handle conversions (where applicable), so that you could then write

operator Explicit(C: Celsius): Fahrenheit;
  result := (C * 9.0/5.0) + 32.0


var OvenTemperature: Fahrenheit := Fahrenheit(BoilingTemp);

See Also