Operators
Munos follows familiar C/JavaScript operator conventions. One emphasis worth noting: bitwise operators are first-class and expected — flag packing, tile decoding, and memory-layout work are everyday tasks for retro modders.
A rule that applies throughout: binary operators require both operands to have the same type. There are no implicit conversions, so mixing a u8 and an i32 is an error — cast first.
Arithmetic
+ - * / %
Same integer type in, same type out. Integer division truncates toward zero. Overflow wraps.
var a = 7 / 2 // 3
var b = -7 / 2 // -3 (toward zero)
var c = 7 % 2 // 1Comparison
== != < > <= >=
Return bool. Operands must share a type. Strings compare by byte sequence.
Logical
&& || !
Boolean operators with short-circuit evaluation. Operands must be bool — numbers and strings are not coerced.
if occupied[i] && x > 0 { … }Bitwise
& | ^ ~ << >>
AND, OR, XOR, complement, left shift, right shift. Operands must be the same integer type. Right shift is arithmetic (sign-extending) on signed types and logical (zero-filling) on unsigned types.
var key = (hi << 8) | lo // pack two bytes
var facing_right = (flags & 0x40) != 0Assignment
= assigns. Compound forms apply an operator in place:
+= -= *= /= %= &= |= ^= <<= >>=x op= y is exactly x = x op y.
score += 100
flags &= ~0x40Precedence
Highest to lowest:
| # | Operators |
|---|---|
| 1 | unary ! ~ - |
| 2 | * / % |
| 3 | + - |
| 4 | << >> |
| 5 | < > <= >= |
| 6 | == != |
| 7 | & |
| 8 | ^ |
| 9 | | |
| 10 | && |
| 11 | || |
Use parentheses whenever precedence isn't obvious — bitwise-and-shift mixes in particular read better parenthesized.