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>
This commit is contained in:
parent
7cbd5d175c
commit
6c6dfae235
6 changed files with 119 additions and 1 deletions
24
docs/language/annotations/annot-namespace.md
Normal file
24
docs/language/annotations/annot-namespace.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
id: annot-namespace
|
||||
name: @Namespace
|
||||
category: annotations
|
||||
kind: annotation
|
||||
tokens: @Namespace
|
||||
sig: "@Namespace(Name) function name_method(…) -> T { … }"
|
||||
tip: Let a package provide a Name.method(…) namespace that dispatches to name_method.
|
||||
order: 61
|
||||
---
|
||||
|
||||
<code>@Namespace(Name)</code> registers <code>Name</code> as a namespace a package provides, so a caller can write <code>Name.method(…)</code> and the compiler dispatches it to the bare function <code>name_method(…)</code> (the namespace lowercased, an underscore, then the method). It is the package-declarable form of the built-in <code>Foo.*</code> stdlib namespaces (<code>Regex.*</code>, <code>Grid.*</code>, …): a third-party package ships the same call shape without editing the compiler. The alias goes through the same generic call path the core namespaces use and preserves the target function's return type; it only applies after every built-in namespace, so it never shadows a core one. Mark each function that backs a method (the registration is idempotent — one mark is enough to open the namespace, but marking each provider documents the surface).
|
||||
|
||||
```ludic
|
||||
program NamespaceDemo {
|
||||
@Namespace(Coach) function coach_bonus() -> int { return 99 }
|
||||
@Namespace(Coach) function coach_double(n: int) -> int { return n + n }
|
||||
|
||||
entry {
|
||||
print(Coach.bonus()) # 99 — dispatches to coach_bonus
|
||||
print(Coach.double(21)) # 42 — dispatches to coach_double
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue