Nullable types are special value types, created with the predefined System.Nullable[T] generic type, and a value type as its type argument, and having special support by the compiler. They were designed to support null values as in SQL.
The Nullable[T] class is declared like this:
Nullable = record[record T] // ... end;
Two obvious consequences can be inferred from the above declaration:
There's another constraint that cannot be inferred from the Nullable's declaration: though value types are the only acceptable types, you cannot pass another nullable type in the generic type parameter:
var n1: Nullable[Byte]; // Allowed. n2: Nullable[String]; // Error! String is a reference type. n3: Nullable[Nullable[Byte]]; // Error! Nullable cannot be nested.
Instead of explicitly using the Nullable type identifier, Freya allows you to declare a nullable type by appending a question mark to the base type reference:
var n1: Byte?;
The Freya Programming Language
Constructed types
Null coalescing operator
Records declarations
Class declarations
Generic types
Type declarations