Skip to main content

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.
OperationSyntaxNotes
Unary plus+aEquivalent to abs(a) — returns the absolute value
Unary minus-aNegates a
Incrementa++Postfix; returns the old value, then adds 1
Decrementa--Postfix; returns the old value, then subtracts 1
Additiona + bAlso concatenates str values
Subtractiona - b
Multiplicationa * b
Divisiona / bInteger division produces a float
Moduloa % 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).
OperationSyntaxNotes
Equala == bValue equality only
Not equala != bValue inequality
Type-equala === bBoth same type and same value
Type-not-equala !== bType or value differs
Greater thana > b
Less thana < b
Greater or equala >= b
Less or equala <= b
Membershipa in bb 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

OperationSyntaxNotes
NOT!aUnary; negates truthiness
ANDa && bShort-circuits on falsy a
ORa || bShort-circuits on truthy a
XORa ^^ bTRUE 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.
OperationSyntax
Bitwise NOT~a
Bitwise ANDa & b
Bitwise ORa | b
Bitwise XORa ^ b
Shift lefta << b
Shift righta >> b

Assignment operators

All compound assignment operators expand to variable = variable OP value.
SyntaxEquivalentStatus
a = bplain assignment✓ implemented
a += ba = a + b✓ implemented
a -= ba = a - b✓ implemented
a *= ba = a * b✓ implemented
a /= ba = a / b✓ implemented
a %= ba = a % b✓ implemented
a &&= ba = a && b✓ implemented
a ||= ba = a || b✓ implemented
a ^^= ba = a ^^ b✓ implemented
a &= ba = a & b⚠ planned — lexed but not yet executed
a |= ba = a | b⚠ planned — lexed but not yet executed
a ^= ba = 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):
LevelOperatorsAssociativity
1 (lowest)=, +=, -=, …Right
2||, ^^Left
3&&Left
4==, !=, ===, !==Left
5<, >, <=, >=, inLeft
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
};

Build docs developers (and LLMs) love