Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ToberlerOhn/hades/llms.txt
Use this file to discover all available pages before exploring further.
Hades provides a rich set of operators drawn from the C family, with a few unique additions such as strict type-equality (===), logical XOR (^^), and the membership operator (in).
Arithmetic operators
Arithmetic operators work on int and float values. Mixing types follows standard numeric promotion rules.
| Operation | Syntax | Notes |
|---|
| Unary plus | +a | Equivalent to abs(a) — returns the absolute value |
| Unary minus | -a | Negates a |
| Increment | a++ | Postfix; returns the old value, then adds 1 |
| Decrement | a-- | Postfix; returns the old value, then subtracts 1 |
| Addition | a + b | Also concatenates str values |
| Subtraction | a - b | |
| Multiplication | a * b | |
| Division | a / b | Integer division produces a float |
| Modulo | a % b | |
Exponentiation is not an operator in Hades. Use the built-in function pow(base, exponent) instead.
x: int = -5;
print(+x); // 5 (absolute value)
print(x++); // -5 (old value returned, x is now -4)
print(x); // -4
Comparison operators
Comparison operators evaluate to bool (TRUE or FALSE).
| Operation | Syntax | Notes |
|---|
| Equal | a == b | Value equality only |
| Not equal | a != b | Value inequality |
| Type-equal | a === b | Both same type and same value |
| Type-not-equal | a !== b | Type or value differs |
| Greater than | a > b | |
| Less than | a < b | |
| Greater or equal | a >= b | |
| Less or equal | a <= b | |
| Membership | a in b | b must be a list or str |
print(1 == 1.0); // TRUE — same value, different types
print(1 === 1.0); // FALSE — types differ (int vs float)
print(1 !== 1.0); // TRUE
print('lo' in 'hello'); // TRUE
print(42 in [10, 42, 99]); // TRUE
When using in with a str on the right-hand side, the left-hand operand must also be a str. Passing a non-string raises a runtime error.
Logical operators
| Operation | Syntax | Notes |
|---|
| NOT | !a | Unary; negates truthiness |
| AND | a && b | Short-circuits on falsy a |
| OR | a || b | Short-circuits on truthy a |
| XOR | a ^^ b | TRUE when exactly one operand is truthy |
print(!FALSE); // TRUE
print(TRUE && FALSE); // FALSE
print(FALSE || TRUE); // TRUE
print(TRUE ^^ TRUE); // FALSE
print(TRUE ^^ FALSE); // TRUE
Bitwise operators
The following bitwise operators are part of the Hades language specification and are listed in the README, but they are not yet implemented in the current interpreter. Using them at runtime will raise an error. They are documented here as planned features.
| Operation | Syntax |
|---|
| Bitwise NOT | ~a |
| Bitwise AND | a & b |
| Bitwise OR | a | b |
| Bitwise XOR | a ^ b |
| Shift left | a << b |
| Shift right | a >> b |
Assignment operators
All compound assignment operators expand to variable = variable OP value.
| Syntax | Equivalent | Status |
|---|
a = b | plain assignment | ✓ implemented |
a += b | a = a + b | ✓ implemented |
a -= b | a = a - b | ✓ implemented |
a *= b | a = a * b | ✓ implemented |
a /= b | a = a / b | ✓ implemented |
a %= b | a = a % b | ✓ implemented |
a &&= b | a = a && b | ✓ implemented |
a ||= b | a = a || b | ✓ implemented |
a ^^= b | a = a ^^ b | ✓ implemented |
a &= b | a = a & b | ⚠ planned — lexed but not yet executed |
a |= b | a = a | b | ⚠ planned — lexed but not yet executed |
a ^= b | a = a ^ b | ⚠ planned — lexed but not yet executed |
score: int = 10;
score += 5; // 15
score *= 2; // 30
score %= 7; // 2
Operator precedence
Operators are evaluated in the following order (highest precedence last in the list means it binds tightest):
| Level | Operators | Associativity |
|---|
| 1 (lowest) | =, +=, -=, … | Right |
| 2 | ||, ^^ | Left |
| 3 | && | Left |
| 4 | ==, !=, ===, !== | Left |
| 5 | <, >, <=, >=, in | Left |
| 6 | +, - | Left |
| 7 | *, /, % | Left |
| 8 | !, unary -, unary + | Right |
| 9 | ++, -- (postfix) | Left |
| 10 (highest) | literals, identifiers, () | — |
Operator overloading
Operator overloading is part of the Hades class system. Class and struct execution is not yet supported by the current interpreter — class definitions are parsed but not evaluated at runtime. The syntax below reflects the planned grammar; see Classes & Structs for full details.
Inside a class, you can redefine how an operator behaves on instances using the operator keyword:
// Planned syntax — classes are not yet executed by the interpreter
operator !(me) => bool {
if (my.name && my.age && my.year && my.gpa) {
=> FALSE
}
=> TRUE
};