Skip to content

Types

Zeus is a statically typed language. Every variable, parameter, and return value has a type known at compile time.

Primitive Types

Integer Types

Zeus provides signed and unsigned integers of various sizes:

TypeSizeRange
i88-bit-128 to 127
i1616-bit-32,768 to 32,767
i3232-bit-2.1B to 2.1B
i6464-bit-9.2×10¹⁸ to 9.2×10¹⁸
u88-bit0 to 255
u1616-bit0 to 65,535
u3232-bit0 to 4.2B
u6464-bit0 to 1.8×10¹⁹
let small: i8 = 127;
let normal: i32 = 1000000;
let big: i64 = 9223372036854775807;
let positive: u32 = 4000000000;

Floating-Point Types

TypeSizePrecision
f3232-bit~7 decimal digits
f6464-bit~15 decimal digits
let pi: f32 = 3.14159;
let precise: f64 = 3.141592653589793;

Boolean Type

The boolean type has two values: true and false.

let isReady: boolean = true;
let hasError: boolean = false;

Void Type

void is used only as a function return type to indicate no value is returned:

function logMessage(): void {
// No return statement needed
}

Null

null represents the absence of a value for object types:

let p: Point = null;

Numeric Literals

Integer Literals

Zeus supports multiple number bases:

let decimal: i32 = 42;
let binary: i32 = 0b101010; // 42 in binary
let octal: i32 = 0o52; // 42 in octal
let hex: i32 = 0x2A; // 42 in hexadecimal

Use underscores for readability:

let million: i32 = 1_000_000;
let binary: i32 = 0b1111_0000;

Floating-Point Literals

let simple: f64 = 3.14;
let scientific: f64 = 6.022e23; // Scientific notation

Type Compatibility

Implicit Conversions

Zeus performs automatic widening conversions:

let small: i8 = 10;
let big: i32 = small; // OK: i8 → i32
let integer: i32 = 42;
let floating: f64 = integer; // OK: i32 → f64

Allowed implicit conversions:

  • Smaller integers → larger integers (e.g., i8i32)
  • Integers → floats (e.g., i32f64)
  • null → any object type
  • stringu8[] (creates a copy)

Type Errors

Narrowing conversions are not allowed:

let big: i32 = 1000;
let small: i8 = big; // Error: cannot convert i32 to i8

Incompatible types cause errors:

let num: i32 = 42;
let flag: boolean = num; // Error: cannot convert i32 to boolean

Complex Types

Strings

The string type represents immutable UTF-8 text:

let greeting: string = "Hello, World!";
let emoji: string = "Zeus 🚀";

Strings can be implicitly converted to u8[] (mutable byte array) and vice versa:

let text: string = "Hello";
let bytes: u8[] = text; // Creates mutable copy
bytes[0] = 'h'; // Modify the copy
let modified: string = bytes; // Back to string

See Strings for more details.

Arrays

Arrays are declared with Type[] syntax:

let numbers: i32[] = new i32[];
let matrix: f64[][] = new f64[][]; // 2D array

See Arrays for more details.

Classes

Classes define custom object types:

class Rectangle {
public width: f64;
public height: f64;
}
let rect: Rectangle = new Rectangle();

See Classes for more details.

Function Types

Functions can be stored in variables:

function add(a: i32, b: i32): i32 {
return a + b;
}
let operation: function(i32, i32): i32 = add;

Type Checking

Zeus performs thorough type checking at compile time:

function process(value: i32): boolean {
return value > 0;
}
function main(): i32 {
let result: boolean = process(42); // OK
// let wrong: i32 = process(42); // Error: boolean not assignable to i32
// process("hello"); // Error: string not assignable to i32
return 0;
}

Next

Functions →