`namespace Name { export function foo(...) ... internal function bar(...) ... }`
declares a Name.* namespace once and controls its public surface declaratively,
instead of annotating every function with @Namespace(Name). Inside the block
each `function short(...)` is emitted as `namelower_short`; export (the default)
makes it callable as Name.short(...), internal keeps it a private helper
(emitted, callable by short name from siblings — calls are rewritten — but
Name.internalOne() is a compile error). Block sugar for the per-function
@Namespace annotation; a package's public API reads at a glance. Namespaces
declared the old way are unchanged (gameplay_foundation still passes).
namespace added to LUDIC_KW_DECL + JetBrains/TextMate + docs page + inventory
(vocab/impl/docs checks green). Example namespace_block (export + internal +
sibling calls + internal-visibility compile error verified). Full suite 116/0,
fixpoint holds.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
20 lines
943 B
Text
20 lines
943 B
Text
# namespace_block.ludic — the `namespace Name { ... }` block form (#76). Declares
|
|
# the namespace once and controls its public surface declaratively: `export`
|
|
# functions are callable as Name.method, `internal` ones are private helpers.
|
|
# Sibling calls inside the block use the short name.
|
|
#
|
|
# Deterministic; a full run prints: 15 42 100
|
|
program NamespaceBlock {
|
|
namespace Combat {
|
|
export function amount() -> int { return base() + 5 } # calls the internal sibling by short name
|
|
internal function base() -> int { return 10 } # a private helper — not Combat.base
|
|
export function double(n: int) -> int { return n + n }
|
|
export function via_internal() -> int { return base() * 10 }
|
|
}
|
|
|
|
entry {
|
|
print(Combat.amount()) # 15 — 10 (internal base) + 5
|
|
print(Combat.double(21)) # 42
|
|
print(Combat.via_internal()) # 100 — reaches the internal helper from inside the namespace
|
|
}
|
|
}
|