Fundamentals
Variables
Section titled “Variables”Three declaration keywords with distinct semantics:
| Keyword | Meaning |
|---|---|
const | Compile-time constant. Never changes. |
let | Runtime immutable. Assigned once. |
var | Mutable. Can be reassigned. |
const MAX_HEALTH = 100.0
let name = "Hero" // type inferred from valuelet name: string = "Hero" // explicit type
var health = 100.0health = 80.0 // okname = "Villain" // compile error — let is immutableTypes are non-nullable by default. See Error Handling for Optional<T>.
Primitive types
Section titled “Primitive types”| Writ type | Description |
|---|---|
int | Integer. Stored as i32, automatically promoted to i64 on overflow. |
float | Floating point. Stored as f32, promoted to f64 when precision needs it. |
bool | true or false. |
string | UTF-8 text. |
The VM picks the smallest representation that fits and promotes transparently — scripts always see int and float.
let x: int = 42let y: float = 3.15let alive: bool = truelet name: string = "Hero"Naming conventions
Section titled “Naming conventions”| Kind | Convention | Example |
|---|---|---|
| Primitives | lowercase | int, float, string |
| User-defined types | PascalCase | Player, Entity, Weapon |
| Methods and functions | camelCase | takeDamage, getHealth |
| Fields | camelCase | maxHealth, currentSpeed |
| Enum variants | PascalCase | Direction.North |
Strings
Section titled “Strings”let name = "Hero"
// Interpolationlet greeting = "Hello, $name!"let msg = "HP: ${player.health}"let calc = "Total: ${a + b}"
// Escape the dollar signlet literal = "Cost: \$50"
// Multi-linelet block = """ Player: $name Health: $health """
// Concatenationlet full = "Hello" .. ", " .. nameOperators
Section titled “Operators”Arithmetic
Section titled “Arithmetic”a + b // adda - b // subtracta * b // multiplya / b // dividea % b // moduloComparison
Section titled “Comparison”a == b a != ba < b a > ba <= b a >= bLogical
Section titled “Logical”a && b // anda || b // or!a // notAssignment
Section titled “Assignment”x = 10x += 5x -= 2x *= 3x /= 2x %= 4| Operator | Meaning |
|---|---|
?? | Null coalescing — use right side if left is null |
?. | Safe member access — short-circuits to null |
? | Error propagation — return early on failure |
.. | String concatenation |
... | Spread into array or dict |
as | Type cast |
a ? b : c | Ternary |
Ranges
Section titled “Ranges”0..10 // exclusive: 0 to 90..=10 // inclusive: 0 to 10Comments
Section titled “Comments”// Single line
/* Multi line comment */
// Doc comment — placed directly above a declaration// The type checker and tooling pick these up automatically.func takeDamage(amount: float) { }Blocks and semicolons
Section titled “Blocks and semicolons”Curly braces delimit blocks. Semicolons are optional — newlines terminate statements. Unclosed brackets defer termination to their closing bracket:
let x = 10let x = 10; // also valid
let result = someFunction( arg1, arg2 // newline ignored inside parens)