Language reference

This section documents all Quadrate keywords and built-in instructions.

Quick navigation

Types

Quadrate has five basic types:

Type Description Example
i64 64-bit signed integer 42, -17
f64 64-bit floating-point 3.14, -0.5
d128 Decimal floating-point, 34 digits 0.1d, 19.99d
str String "hello"
ptr Raw memory mem::alloc, C handles

Stack signatures

Function signatures use (inputs -- outputs) notation:

fn sum(a:i64 b:i64 -- s:i64) { + }
  • Before --: Values consumed from stack (bottom to top)
  • After --: Values produced on stack (bottom to top)

Fallible functions

Functions that can fail are marked with !:

fn divide(a:i64 b:i64 -- result:i64)! {
    // Can signal error
}

Test the status with ok if (or fail if, or a switch on it) to handle errors:

10 2 divide ok if {
    // success: the result is on the stack
    print nl
} else {
    // failure: a zero placeholder stands where the result would be
    drop
}