Object oriented

Imports & visibility

A file can invite another file over. public is the front door. private is the rest of the house.

Classes live next door: fields, constructor, methods, self, newobj. Inheritance is further down the hall: extends, parent, override, abstract. Same manners.

import

Pass a filename as a string. After that, you may call the public functions defined there — and create public classes with newobj.

import "Addition.alana";
showln call Add(10, 50);

Reference: import.

private / public

In the imported file, group fields and functions under private: and public:. Private stays in that file. Public is what Main.alana is allowed to see. The same labels work inside a class, to hide fields and keep methods at the door.

private:
    define num x is new;
    define num y is new;

public:
    define func Add(num left, num right);
        redefine x is left;
        redefine y is right;
        return x + y;
    end;

including

A different door. including opens a runtime library, not a neighbour file. That is how the standard library arrives: HTTP, JSON, errors.

including "stdlib/http.alana";
including "stdlib/json.alana";
including "stdlib/error.alana";

Full two-file walkthrough: Imports and public/private fields.