Types
ROX is a statically typed language. All types must be explicit.
Primitive Types
num 64-bit Signed Integer
The default integer type. Used for most arithmetic and list indexing.
num x = 42;
num y = -100;
num32 32-bit Signed Integer
A smaller integer type, useful for compatibility or memory optimization.
num32 i = 10n; // 'n' suffix denotes num32 literal
bool Boolean
Values: true or false.
bool is_valid = true;
if (is_valid) { ... }
char Character
Represents a single ASCII character.
char c = 'A';
string String
Immutable sequence of bytes (UTF-8). Literals use double quotes.
string s = "Hello";
num len = s.size();
rox_result[char] c = s.at(0);
list[char] chars = s.toList();
print(s); // Prints "Hello"
none Unit Type
Represents the absence of a value (similar to void in C++). Used as the return type for functions
that do not return data.
function log() -> none {
print(['H','i','\n']);
return none;
}
Result Type
rox_result[T]
ROX does not use exceptions. Operations that can fail return a rox_result[T].
You must check if the result is valid using isOk() before extracting the value with
getValue().
rox_result[num] result = list.at(5);
if (isOk(result)) {
num val = getValue(result);
} else {
// Handle error
}