Types
Munos is statically typed with a small, fixed set of types. Types are known at compile time; the runtime never reasons about types. Annotations use a TypeScript-style name: type shape.
Primitive types
Integers
| Type | Bits | Signed | Range |
|---|---|---|---|
i8 | 8 | yes | −128 … 127 |
i16 | 16 | yes | −32 768 … 32 767 |
i32 | 32 | yes | −2 147 483 648 … 2 147 483 647 |
u8 | 8 | no | 0 … 255 |
u16 | 16 | no | 0 … 65 535 |
u32 | 32 | no | 0 … 4 294 967 295 |
Two's complement; arithmetic overflow wraps. Single-byte memory reads return u8; address constants are typically u16 or u32.
There is no floating-point type in Munos, by design — retro consoles are integer machines, and integer-only execution stays bit-identical across every client.
bool
Values true and false. There is no coercion between numbers and bool.
string
An immutable byte sequence. Operations: literal, concatenation (+, both operands must be strings), len(), byte-indexed access, equality. The recommended interchange subset is 7-bit ASCII.
var name: string = "Mario"
var greeting = "hello " + name+ on strings requires string operands — there is no implicit number-to-string conversion. To print a number alongside text, use the variadic print:
print("score: ", score) // ok
print("score: " + score) // type errorimage
A mutable 2D buffer of palette indices — width × height of u8. Each pixel is an index resolved against a palette at draw time, not an RGB color. Index 0 is conventionally transparent. See Images & drawing for construction and use.
client
An opaque handle to a connected client, used only in server code. Stable for the duration of that client's connection. You can compare two client values for equality but cannot inspect or construct one — the runtime is the sole source. See Server & slots.
Palettes
A palette is not a distinct type — it's an array of colors, u32[]. Each entry holds a packed 0x00RRGGBB color in its low 24 bits (red high, blue low). The high byte is ignored by the compositor.
var pal: u32[] = [0x00000000, 0x00FF0000, 0x0000FF00, 0x000000FF]
// transparent red green blueTransparency is by index, not by color: palette index 0 is always transparent, whatever value you store there. A typical palette has up to 256 entries (matching the u8 index range), but any size works as long as the script only indexes valid entries — an out-of-range index is skipped at draw time.
Composite types
Beyond primitives, compose data with arrays (T[]) and user-declared structs.
Conversions
There is no implicit conversion between types, including between integer widths. Convert explicitly with a cast named after the target type:
i8(x) i16(x) i32(x)
u8(x) u16(x) u32(x)Narrowing casts truncate. A cast takes exactly one integer argument.
var raw: u8 = read_u8(0x0086)
var x: i32 = i32(raw)Numeric literals default to i32 when their type can't be inferred from context. Assigning a literal into a smaller type is allowed when the value fits at compile time (var b: i8 = 100 is fine; var b: i8 = 300 is a compile error).
Literals
- Integers — decimal (
42), hex (0x2A), binary (0b101010). Underscores may appear anywhere for readability:1_000_000,0xDEAD_BEEF. - Strings — double-quoted. Escapes:
\n\t\r\\\"\0and\xHH(raw byte). - Booleans —
true,false.