Documentation
¶
Overview ¶
Package structrt provides the runtime glue the bytecode generator emits when lowering a `struct` declaration. It installs ONE global helper, `__struct_define(name, fieldNames) -> constructor`, mirroring the way native/enumrt installs `__enum_freeze`.
A `struct Point { x: number, y: number }` lowers to
local Point = __struct_define("Point", {"x", "y"})
The returned constructor is a plain callable. It supports both call forms the language exposes:
Point(1, 2) -- positional: fields assigned in declaration order
Point{ x = 1, y = 2 } -- named: Lua's `f{}` call sugar, one table arg
A single table argument is treated as NAMED construction unless it carries an array element at index 1 (in which case it is positional). Instances carry a metatable whose `__type` is the struct name — so `typeof(p)` reports "Point" — and a `__tostring` for readable printing. Instances are ordinary mutable tables otherwise (records, not frozen values).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterStructRT ¶
RegisterStructRT installs __struct_define on the VM globals. Idempotent, like the other runtime registrars, so the REPL can replay it on :reset.
Types ¶
This section is empty.