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)

Because there's no implicit number-to-string conversion, print is how you display a number next to text — don't try "score: " + score (that's a type error; + on strings needs string operands).

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

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

Part of the MultiNostalgia project.