Hades is a statically-typed language, but its conditional and logical constructs accept values of any type — not justDocumentation 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.
bool. When a non-boolean value appears in a context that demands a truth value (an if condition, a while guard, a logical operator operand), the interpreter applies a set of rules called truthiness to decide whether the value counts as TRUE or FALSE. Understanding these rules is essential for writing correct conditional logic in Hades.
Where Truthiness Applies
Truthiness is evaluated in four situations:ifconditions —if (expr)evaluatesexprfor truthiness.while/do-whileconditions — the loop continues while the condition is truthy.- Logical operators —
&&,||, and^^test each operand’s truthiness. - Logical NOT —
!valuereturnsTRUEifvalueis falsy,FALSEif it is truthy.
Truthiness Rules by Type
The interpreter’s_truthy function determines truth in this exact order:
nothing(PythonNone) → always falsybool→ the value itself (TRUEtruthy,FALSEfalsy)intorfloat→ truthy if not equal to zerostr→ truthy if not the empty string- Everything else (e.g. lists) → delegates to Python’s
bool(), which means non-empty collections are truthy
Type-by-Type Reference
nothing
Always falsy. A
nothing variable holds no value. There is no truthy variant of nothing.bool
TRUE is truthy; FALSE is falsy. Booleans evaluate as themselves — no conversion needed.int
Any non-zero integer is truthy. Zero (
0) is the sole falsy integer.float
Any non-zero float is truthy. Zero (
0.0) is falsy.str
Any non-empty string is truthy. The empty string
'' is falsy.list
A list with at least one element is truthy. An empty list
[] is falsy.Full Reference Table
The rows marked Planned describe types that appear in the Hades README but are not yet implemented in the lexer or interpreter. Their truthiness semantics are theoretical and subject to change.| Type | Truthy | Falsy | Status |
|---|---|---|---|
nothing | (never truthy) | all nothing values | Implemented |
bool | TRUE | FALSE | Implemented |
int | any value ≠ 0 | 0 | Implemented |
float | any value ≠ 0.0 | 0.0 | Implemented |
str | any non-empty string | '' (empty string) | Implemented |
list | any non-empty list | [] (empty list) | Implemented |
record | any non-empty record | "" (empty record) | Planned |
structure | any structure with at least one field set | structure with no values | Planned |
Code Examples by Type
nothing
bool
int
float
str
list
Logical Operators and Truthiness
The binary logical operators&&, ||, and ^^ all use truthiness on both operands. They do not require either side to be a declared bool.
In Hades, logical operators return a
bool result (TRUE or FALSE), not the operand value itself. This differs from languages like JavaScript where || and && return one of their operands.Logical NOT and Truthiness
The prefix! operator converts any value to a boolean using truthiness and returns its negation.