Skip to content

l0.DependencyControl.Accessors

Accessors = require "l0.DependencyControl.Accessors"
local Accessors = require("l0.DependencyControl.Accessors")

Accessors

Declares metatable-backed get/set computed properties on a class through one standardized transform: property marks a property in a class body; install, called once after the body, wires the instance metatable to dispatch those keys to the getter/setter and records each on the class's __accessors.

Class methods

property

Accessors.property spec
Accessors.property(spec)

Declares a computed property to place at a key in a class body; wire the class up with install. Omitting set makes the property read-only, so a write raises at runtime.

param type description
spec { get?: (fun(self: any): any), set?: (fun(self: any, value: any)) } Getter and/or setter (at least one).

Returns:

  • spec AccessorSpec — Assign this to the property's key in the class body.

install

Accessors.install cls
Accessors.install(cls)

Installs standardized get/set dispatch for every property declared with property in a class's body, plus any inherited from a parent class that ran install, recording each on the class's __accessors registry. Call once, immediately after the class body (and after the parent's install for a subclass). Reading a getter-less property falls through to normal lookup; writing a setter-less one raises.

param type description
cls table The class whose __base carries the property specs.

Returns:

  • cls table — The same class, for chaining.

Types

AccessorSpec

An opaque computed-property spec produced by property and consumed by install. Not indexed directly.

AccessorInfo

Per-property capability flags recorded on a class's __accessors registry after install.