AHK v2 Object Inheritance

AutoHotkey v2 is prototype-based: every value descends from Any, and inheritance flows through two parallel .Base chains — one for instances (the prototype chain) and one for classes (for static members). Explore the built-in type hierarchy below, then see how a user-defined extends maps onto both chains.

Includes v2.1-alpha additions: Struct & the parallel .Ptr hierarchy
Built-in type hierarchy click a type for details · carets expand/collapse
    The two inheritance chains how class Dog extends Animal resolves members

    Prototype chain

    Instance member & method lookup. An instance's .Base is its class's Prototype.

    rexa Dog instance
    Dog.PrototypeSpeak() → "barks"
    Animal.Prototype__New(), Speak()
    Object.PrototypeHasProp, DefineProp…
    Any.PrototypeGetMethod, root

    Class chain

    Static member lookup. A class's .Base is its parent class.

    Dogthe class object
    Animalstatic Kingdom
    Objectimplicit superclass
    Anyroot type
    Both chains are linked: rex.Base == Dog.Prototype and Dog.Prototype.Base == Animal.Prototype, while Dog.Base == Animal. Every class object is itself an instance of Class. Verify any link live with Type(x), x.Base, and the is operator.
    origin object prototype object class object
    Inspect it yourself
    Alpha: Struct inheritance & the parallel .Ptr chain v2.1-alpha.22+

    Struct value classes

    Struct supports extends; a subclass appends its fields to the parent's layout.

    Circle+ radius: Float64
    Shapearea: Float64
    Object → Anyroot types

    Auto-generated .Ptr classes

    Each struct gets a .Ptr view class, and the pointer chain mirrors the value chain.

    Circle.Ptrsubclasses Shape.Ptr
    Shape.Ptrtyped pointer view
    (root)
    Because the pointer hierarchy is parallel, a DllCall or function typed to accept Shape.Ptr will also accept a Circle.Ptr — struct subtyping works across the FFI boundary, not just for AHK-level member lookup.