Skip to content

Variables & Types

Declaring Variables

Variables are declared with their type first, followed by the name:

int age = 25;
float pi = 3.14159;
string name = "Cera";
bool active = true;
char letter = 'A';

Primitive Types

TypeSizeDescription
int64-bitSigned integer (default)
int8, int16, int32, int648-64 bitSized signed integers
uint8, uint16, uint32, uint648-64 bitUnsigned integers
float64-bitFloating point (default)
float32, float6432-64 bitSized floats
string—Text string
char8-bitSingle character
bool—true or false
hash64-bitHash value (via (hash)value)
float32x4, int32x4, etc.128-bitSIMD vector types

Constants (const)

Use const to declare compile-time constants. The value must be computable at compile time:

const int MAX_SIZE = 100;
const float TAU = 6.28318;
const int DOUBLED = MAX_SIZE * 2; // expressions of other consts are fine
int runtimeVar = 5;
const int bad = runtimeVar; // ERROR — not a compile-time value

You can also force any expression to be evaluated at compile time with const (expr):

int x = const (5 + 3); // 8, computed at compile time
int y = const (square(5)); // 25, if square is a const function

Immutability (immut)

Use immut to declare variables that cannot be reassigned or modified after initialization. Unlike const, immut values can be set at runtime — they just can’t change afterwards:

immut int x = ComputeValue(); // runtime value, but frozen after init
x = 10; // ERROR — immut variable
immut Point p = Point(10, 20);
p.x = 5; // ERROR — immut value

Type Conversions

Cast between types explicitly:

int x = 42;
float f = (float)x; // 42.0
int back = (int)3.99; // 3 (truncates)
string s = (string)x; // "42"

Strings

Strings support concatenation with + and have built-in methods:

string greeting = "Hello, " + "world!";
int len = greeting.Length;
string upper = greeting.ToUpper();
string sub = greeting.SubString(0, 5); // "Hello"

Next Steps

Learn how to organize code with functions.