ludic/docs/language/annotations/annot-system.md
Orkuncakilkaya 6c6dfae235
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 20s
ci / build-and-test (push) Successful in 1m41s
commit-lint / conventional-commits (push) Successful in 3s
docs / build-and-deploy (push) Successful in 27s
docs(pkg): document @Namespace / @EngineSystem / @System + package hooks (#62)
Per-annotation pages for the three package-registration annotations (with
inventory entries), a "Package-declarable namespaces and engine systems" section
in docs/PACKAGES.md, and a changeset. All doc gates green (check-docs 675
fences, docs-check 726 symbols).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-01 12:31:47 +03:00

1.4 KiB


id: annot-system name: @System category: annotations kind: annotation tokens: @System sig: "@System(Phase) function name() { … }" tip: Register a prebuilt binary module's system with the host at load, per phase. order: 62

@System(Phase) marks a function in a prebuilt binary module (one compiled with --emit-module) as a runtime-registered system. The module carries a load-time constructor that hands each such function to the host through ludic_register_system, and the host's frame loop calls it every Phase after its own handlers — the runtime, escape-hatch counterpart of the compile-time @EngineSystem. The compiler supplies the function's address (Ludic source cannot take one). This is how a closed-source or other-language module contributes systems over the reflection C-ABI; source packages that compile into the consumer should prefer @EngineSystem. Phases are Input, FixedUpdate, Update, LateUpdate and Render.

program ManaModule {
  function module_init() -> void { world_register_prop("Mana", 2) }   # register a component at load

  @System(Update) function mana_regen() -> void {                     # runs every Update in the host
    let M = world_prop_id("Mana")
    let e = world_query_next(M, 0)
    if e >= 0 { world_set(e, M, 0, world_get(e, M, 0) + 1) }
  }
}