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 defines two ways to bundle related data together: classes, which combine data and behaviour with support for constructors, instance methods, and operator overloading; and structs, which are lightweight named field aggregates with no behaviour of their own.
Class and struct definitions are part of the Hades language specification and grammar, but runtime execution of class and struct definitions is not yet supported by the current interpreter. The ClassDefNode and related AST nodes exist and the parser can describe the grammar, but there is no corresponding handler in the interpreter’s node-handler table. Code using class or struct keywords will not execute correctly in the current release. The syntax documented on this page reflects the planned language design.

Classes

A class definition opens with the class name, a colon, the class keyword, and a body block. Inside the body you place a creator (the constructor), zero or more method definitions, and optional operator overloads.

Defining a class

// Planned syntax — class execution is not yet supported by the interpreter
Student: class {
    creator Student(me, name: str, age: int, year: int, gpa: float) => nothing {
        my.name: str = name;
        my.age:  int = age;
        my.year: int = year;
        my.gpa:  float = gpa;
        print('My name is ', my.name);
    };

    method AgeUp(me) => nothing {
        my.age++;
        my.year++;
    };

    operator !(me) => bool {
        if (my.name && my.age && my.year && my.gpa) {
            => FALSE
        }
        => TRUE
    };
};

creator

The constructor. Always named identically to the class. Receives me as its first parameter (similar to self or this).

method

An instance method. Also receives me as its first parameter, giving access to all instance variables and other methods.

operator

Overloads a built-in operator for instances of this class. Receives me and must declare a return type.

The my. keyword

Inside a creator, method, or operator, use my. to reference or declare instance variables and call other methods on the same instance. It plays the same role as this in Java/C++ or self in Python.
// Inside the creator, declare instance variables with my.name: type = value
my.name: str = name;

// Inside a method, read and mutate them freely
my.age++;

Creating an instance

To instantiate a class, write the class name followed by { } containing the constructor arguments (in order, no labels):
// Planned syntax — class instantiation is not yet supported by the interpreter
Alice: Student = Student{
    'Alice',
    20,
    3,
    3.712
};
Access instance properties and call methods with dot notation:
print(Alice.age);   // 20
Alice.AgeUp();
print(Alice.age);   // 21
Invoke overloaded operators directly:
!Alice   // FALSE — all fields are populated

Operator overloading

Any unary or binary operator can be overloaded per-class using the operator keyword followed by the operator symbol and a function signature:
// Planned syntax — operator overloading requires class execution support
operator !(me) => bool {
    // returns TRUE if the instance is considered "empty"
    if (my.name && my.age && my.year && my.gpa) {
        => FALSE
    }
    => TRUE
}

Structs

A struct is a pure data container — a named schema of typed fields with no methods. Use structs when you need to group a fixed set of values without behaviour.

Defining a struct

// Planned syntax — struct execution is not yet supported by the interpreter
Student: struct = {
    age:        int;
    id:         int;
    university: str;
    gpa:        float
};
Fields are separated by semicolons inside the definition block.

Creating struct instances

Hades plans to support two instantiation styles:
// Planned syntax
Alice: struct<Student> = {21, 82911, 'UMass Amherst', 3.712};
Values are assigned to fields in the order they were declared in the struct definition.

Classes vs. structs at a glance

FeatureClassStruct
Constructorcreator (required)positional or named init
Methodsmethod keywordnone
Operator overloadingoperator keywordnone
Instance keywordmy.field names
Type annotation on instanceClassNamestruct<StructName>
Both classes and structs are planned features of the Hades type system. Follow the project repository for updates on interpreter support.

Build docs developers (and LLMs) love