Namespaces: namespace Foo { ... } block with export/internal visibility, not per-function @Namespace #76
Labels
No labels
area:ci
area:docs
area:input
area:net
area:rendering
area:repo
area:stdlib
area:tooling
area:types
cleanup
dx
priority:high
priority:low
priority:medium
proposal
status:in-progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: workshopsoft/ludic#76
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Today every exported function is annotated one-by-one, e.g.
@Namespace(Combat) function combat_amount() -> int { ... }, scattering a namespace across many annotations and exporting each individually.Proposal: a block form that declares the namespace once and controls visibility declaratively, e.g.
Improves readability and makes a package's public surface obvious. Seen throughout packages/ludic.gameplay and friends.
Shipped in
23e232e(full suite 116/0, goldens byte-identical, fixpoint intact).namespace Name { ... }declares aName.*namespace once and controls its public surface declaratively, instead of the per-function@Namespace(Name):Inside the block each
function short(…)is emitted asnamelower_short; export (the default) makes it callable from anywhere asName.short(…), and internal keeps it a private helper — emitted, and callable by its short name from siblings in the block (sibling calls are rewritten to the emitted name), but not part of theName.*surface: callingCombat.base()is a compile error (Combat.base is internal to namespace Combat). So a package's public API reads at a glance, which is what packages/ludic.gameplay & friends wanted.It is the block sugar for the per-function
@Namespaceannotation and goes through the same dispatch path, so a namespace declared the old way is unchanged (the ludic.gameplay controller tests still pass). Verified byexamples/library/namespace_block.ludic— exported methods dispatch (15 42 100), an internal sibling is reachable from inside, andCombat.base()from outside is a compile error.namespaceis registered across the vocabulary (ludic_syntax.h + JetBrains + TextMate + docs page + inventory) so the vocab/impl/docs checks stay green.