0064. One file per module with selective root-relative imports
- Status: Accepted; no-aliases clause partially superseded by ADR-0073
- Date: 2026-10-31
- Plan: M9.1 Steps 2–3
- Review: Making Tenon plugin-first
Context
Programs need multiple files without fragmenting the grammar or disrupting whole-program type checking, specialization and coherence. Existing phases use bare string names, and method calls already use dot syntax.
Decision
Each file is a module. import a.b { x } loads
a/b.hn relative to the root file's directory and
binds selected public items as bare names. Imports precede
declarations; import and pub are
contextual. Items are private by default; pub applies
to functions, structs, enums, newtypes and interfaces, not impls.
Globs, qualified use sites and re-exports are unsupported in v1.
The no-aliases rule alone is partially superseded by ADR-0073; all
other decisions here remain accepted.
Load and bind the graph, rewrite module items to dotted internal names, and merge into one AST before existing resolution and type checking. Root names remain bare. C function names encode module path segments with lengths to avoid collisions. Sources, expression IDs and function file identities follow ADR-0068. This extends ADR-0006's single grammar.
Alternatives considered
- Qualified
mod.nameuse sites require grammar changes and conflict with existing method postfix syntax. - Importer-relative paths can give one file multiple module names.
- Separate compilation adds complexity while whole-program specialization and coherence still require all declarations.
Consequences
The existing name-keyed phases and single C translation unit remain usable; the binding rewrite must distinguish local references from module items. Aliases and packages are deferred to M9.2; M9.1 Step 4 handles further visibility rules.