Misc
Builtins and compiler forms that don't belong to a single subsystem.
print
print(...) // variadic; any number of printable argumentsprint is variadic — it accepts any mix of printable values (integers, strings, booleans) and writes them in order, followed by a newline. It's the one variadic form in the language (a compiler special-cased feature, since Munos has no user-level varargs).
print("score: ", score, " lives: ", lives)print takes each argument separately and renders it in place, so it's the simplest way to put a number next to text without building a string first. To build an actual string with a number in it, use +, which coerces an integer operand to its decimal text ("score: " + score) — see Types → string.
print is a development/diagnostic tool; output goes to the host's log.
Casts
i8(x) i16(x) i32(x)
u8(x) u16(x) u32(x)Convert between integer types. A cast takes exactly one integer argument; narrowing truncates. Required wherever types must match, since Munos never converts implicitly. See Types → Conversions.
var x = i32(read_u8(0x0086))Array & string forms
These compiler forms operate on arrays (and len also on strings). Full details on the Arrays page.
len(x) // current length (array or string) → i32
size(x) // capacity (array) → i32
push(arr, v) // append within capacity; traps when full
pop(arr) // remove & return last; traps when empty
copy(x) // independent duplicate (array or string; not structs)var a: i32[] = [1, 2, 3]
print(len(a)) // 3
var b = copy(a)
b[0] = 99 // a unchangedsubstring
substring(s, start, end) // fresh string over bytes [start, end) → stringSlice a string. Returns a new string holding the bytes in the half-open range [start, end) — byte-indexed like s[i] and len(s), since a Munos string is a byte sequence. Both bounds clamp into [0, len(s)], and any end <= start yields "", so computed indices never trap: an over-long end truncates, an inverted or out-of-range pair gives an empty slice. It's the inverse of + concatenation — together they're the string-building pair.
var s: string = "HELLO WORLD"
print(substring(s, 0, 5)) // "HELLO"
print(substring(s, 6, len(s))) // "WORLD"
print(substring(s, 0, 100)) // "HELLO WORLD" (end clamped)
print(substring(s, 4, 4)) // "" (empty)Quick index
| Form | Returns | Notes |
|---|---|---|
print(...) | — | variadic; trailing newline |
i8…u32``(x) | the target type | one integer arg; truncates |
len(x) | i32 | array or string |
size(x) | i32 | array capacity |
push(a, v) | — | traps at capacity |
pop(a) | element type | traps when empty |
copy(x) | type of x | arrays/strings only |
substring(s, start, end) | string | bytes [start, end); bounds clamped |