Built-in types
The types, functions and namespaces that the compiler provides itself: they need no using. Their declarations (for this documentation) are in stdlib/builtin.
| Type | Description |
|---|---|
Array<T> |
An array, T[]: a fixed number of values, created with new T[n] (zeroed) or new T[] { a, b } / [a, b]. |
Fixed<T, |
A fixed-size array stored inline: Fixed<int, 16> is 16 ints inside the variable or struct, with no allocation. |
Slice<T> |
A view of a part of an array: a[i..j], a[..j], a[i..]. |
ReadOnlySlice<T> |
A read-only view of elements: a Slice, an array, or a constant (const ReadOnlySlice<int> Primes = [2, 3, 5];, Enum<T>.Values, embed("*.txt")). |
StringSlice |
A view of a part of a string: s[i..j], and the results of String.Trim, String.Split and String.Substring. |
Action |
A function value without a result: Action<int, string> takes an int and a string. |
Func |
A function value with a result: the last type argument is the result, Func<int, int, int> takes two ints and returns an int. |
Enum<T> |
Facts about an enum type, all of them constants (usable in other constants too). |
int8 |
A signed 8-bit integer. |
int16 |
A signed 16-bit integer. |
int32 |
A signed 32-bit integer; int is the same type. |
int64 |
A signed 64-bit integer. |
uint8 |
An unsigned 8-bit integer (a byte); it converts implicitly to and from char. |
uint16 |
An unsigned 16-bit integer. |
uint32 |
An unsigned 32-bit integer; uint is the same type. |
uint64 |
An unsigned 64-bit integer. |
nint |
A signed integer of the size of a pointer (64 or 32 bits, like C’s intptr_t). |
nuint |
An unsigned integer of the size of a pointer (like C’s size_t). |
float |
A 32-bit floating point number (IEEE 754 single precision); float32 is the same type. |
double |
A 64-bit floating point number (IEEE 754 double precision); float64 is the same type. |
bool |
true or false. |
char |
A byte of text, a type of its own that converts implicitly to and from uint8 (and to the larger integer types). |
Optional<T> |
A value or nothing (null): the result of a search that can find nothing. |
Error<T> |
A value or an error: the result of something that can fail. |
string |
A string: immutable UTF-8 text. |
Console |
Text output to the console: stdout and stderr. |
Environment |
The running program: ending it, with an exit code or with a panic. |
Memory |
Raw memory (unsafe): allocating and freeing blocks, volatile accesses for hardware registers, and copies of values for other threads. |
Thread |
The handle of a running thread void function: start Work(10) runs it on its own OS thread and returns a Thread right away. |
SharedPtr<T> |
A value in a reference-counted box that threads can share: SharedPtr<T>.Create(value) moves the value into the box, copies of the SharedPtr share it, and the last one frees it. |