Skip to content

Misc

Builtins and compiler forms that don't belong to a single subsystem.

print

munos
print(...)   // variadic; any number of printable arguments

print 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).

munos
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

munos
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.

munos
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.

munos
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)
munos
var a: i32[] = [1, 2, 3]
print(len(a))      // 3
var b = copy(a)
b[0] = 99          // a unchanged

substring

munos
substring(s, start, end)   // fresh string over bytes [start, end) → string

Slice 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.

munos
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

FormReturnsNotes
print(...)variadic; trailing newline
i8u32``(x)the target typeone integer arg; truncates
len(x)i32array or string
size(x)i32array capacity
push(a, v)traps at capacity
pop(a)element typetraps when empty
copy(x)type of xarrays/strings only
substring(s, start, end)stringbytes [start, end); bounds clamped

Part of the MultiNostalgia project.