-
Notifications
You must be signed in to change notification settings - Fork 0
Declarations
Supported declaration forms, end to end:
- Classes and interfaces (pure-virtual).
-
Enums — pre-C++11
struct E_ { enum … }. A parameterized enum —Add(a:Int, b:Int)— lowers to the tagged-value idiom: the same tag enum plus a copyable value class with per-variant payload fields and inline static factories,Op::Add(1, 2), so ADT values construct, pass, and store by value with no heap or union, plus structural==/!=— same tag, equal payload, with pointer payloads compared by address (Haxe compares enum values by constructor + arguments viaType.enumEq); a recursive payload is flagged — a by-value class cannot contain itself. -
enum abstract— anIntbacking reuses the enum idiom with explicit member values, including sibling-referencing bit-flag expressions likeAB = A | B; aString/Floatbacking becomes a namespace of typedstatic constconstants,namespace X_ { static const std::string A = "…"; }, with the type mapping straight to its underlying C++ type. -
Typedef structs and aliases, the fixed-width
UInt8/16/32shims, andexterninterop wiring (which emits no code of its own, only the includes it contributes).
Mutually-recursive classes in one module need no manual ordering: Hatchet emits a targeted
forward declaration (class B;) for any class/interface/ADT it defines that is referenced before
its own definition — and only those, never extern types. (A forward declaration uses the type's
emitted name, so a @:native-renamed type is declared under its renamed name.) Since Hatchet classes
are reference types (every cross-class member/param/return is a pointer), a forward declaration is
always sufficient, so cyclic type graphs "just work".
Related: Value Types & Abstracts for value classes and abstract Name(U)
newtypes, and Metadata for @:native and the extern keyword.
Hatchet is licensed under the MIT License — see LICENSE. (c) 2026 Andrew Grant Lind
Getting Started
Language Support
- Declarations
- Value Types & Abstracts
- Members & Access
- Statements & Expressions
- Types & Nullability
- Conditional Compilation
- Memory Ownership
Semantics & Interop
Internals