Type System
Cyrus features a strong and expressive type system. The compiler performs implicit type conversions when it is safe, and requires explicit casts when conversions could be unsafe or lossy.
Safe Implicit Casting
If a type can be safely converted to another type without losing information, Cyrus will perform the conversion automatically.
var a: int32 = 42;
var b: int64 = a; // Implicit cast from int32 to int64
int32(32-bit signed integer) can always fit intoint64(64-bit signed integer).- The compiler handles this implicitly, so no special syntax is required.
- Safe casts also apply to numeric literals, e.g.,
#x: float64 = 10.0is allowed.
Unsafe / Explicit Casting
If a conversion could be unsafe, the compiler requires an explicit cast using the cast keyword.
var u: uint32 = 10;
var i: int64 = cast(int64, u); // Explicit unsafe cast from uint32 to int64
Basic Types
Cyrus provides a set of built-in types for numbers, characters, booleans, and special-purpose values. These are the fundamental building blocks of your programs.
| Type | Category | Bit Width | Signedness |
|---|---|---|---|
| int | Signed Integer (default) | Target-dependent (usually 32 or 64) | Signed |
| int8 | Signed Integer | 8 | Signed |
| int16 | Signed Integer | 16 | Signed |
| int32 | Signed Integer | 32 | Signed |
| int64 | Signed Integer | 64 | Signed |
| int128 | Signed Integer | 128 | Signed |
| uint | Unsigned Integer (default) | Target-dependent (usually 32 or 64) | Unsigned |
| uint8 | Unsigned Integer | 8 | Unsigned |
| uint16 | Unsigned Integer | 16 | Unsigned |
| uint32 | Unsigned Integer | 32 | Unsigned |
| uint64 | Unsigned Integer | 64 | Unsigned |
| uint128 | Unsigned Integer | 128 | Unsigned |
| intptr | Pointer-sized Integer | Pointer width (32 or 64) | Signed |
| uintptr | Pointer-sized Integer | Pointer width (32 or 64) | Unsigned |
| size_t | Size / Index Type | Pointer width (32 or 64) | Unsigned |
Floating-Point Types
| Type | Description | Precision |
|---|---|---|
| float16 | 16-bit floating-point number (half precision) | ~3 decimal digits |
| float32 | 32-bit floating-point number (single precision) | ~7 decimal digits |
| float64 | 64-bit floating-point number (double precision) | ~15–16 decimal digits |
| float128 | 128-bit floating-point number (quadruple precision) | ~34 decimal digits |
Character and Boolean Types
| Type | Description | Notes |
|---|---|---|
| char | A single character unit (one code unit; multi-byte Unicode not allowed in '...'). | Represents ASCII/byte chars only |
| bool | Boolean values, either true or false. | 1-bit storage (typically padded to 8 bits) |
Special Types
| Type | Description | Notes |
|---|---|---|
| void | Represents no value, commonly used for functions that do not return anything. | Return type only |

