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.

#a: int32 = 42;
#b: int64 = a; // Implicit cast from int32 to int64
  • int32 (32-bit signed integer) can always fit into int64 (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.0 is allowed.

Unsafe / Explicit Casting

If a conversion could be unsafe, the compiler requires an explicit cast using the cast keyword.

#u: uint32 = 10;
#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.

TypeCategoryBit WidthSignedness
intSigned Integer (default)Target-dependent (usually 32 or 64)Signed
int8Signed Integer8Signed
int16Signed Integer16Signed
int32Signed Integer32Signed
int64Signed Integer64Signed
int128Signed Integer128Signed
uintUnsigned Integer (default)Target-dependent (usually 32 or 64)Unsigned
uint8Unsigned Integer8Unsigned
uint16Unsigned Integer16Unsigned
uint32Unsigned Integer32Unsigned
uint64Unsigned Integer64Unsigned
uint128Unsigned Integer128Unsigned
intptrPointer-sized IntegerPointer width (32 or 64)Signed
uintptrPointer-sized IntegerPointer width (32 or 64)Unsigned
size_tSize / Index TypePointer width (32 or 64)Unsigned

Floating-Point Types

TypeDescriptionPrecision
float1616-bit floating-point number (half precision)~3 decimal digits
float3232-bit floating-point number (single precision)~7 decimal digits
float6464-bit floating-point number (double precision)~15–16 decimal digits
float128128-bit floating-point number (quadruple precision)~34 decimal digits

Character and Boolean Types

TypeDescriptionNotes
charA single character unit (one code unit; multi-byte Unicode not allowed in '...').Represents ASCII/byte chars only
boolBoolean values, either true or false.1-bit storage (typically padded to 8 bits)

Special Types

TypeDescriptionNotes
voidRepresents no value, commonly used for functions that do not return anything.Return type only