Symbol Import Aliases
Status
Future design. This is intentionally separated from current module artifact, stdlib modularization, and bytecode loading work. Current implemented conflict avoidance is module-qualified access:
ng
import first.module as first;
import second.module as second;
first.name();
second.name();Goal
Allow callers to keep short local names when two modules export symbols with the same public name, without weakening import provenance or trait/impl coherence.
Proposed Syntax
ebnf
ImportDecl := ExportPrefix? "import" ModulePath ImportAlias? ImportList? ";"
ExportPrefix := "export"
ImportAlias := "as" Ident
ImportList := "(" ("*" | ImportItem ("," ImportItem)*) ")"
ImportItem := Ident ("as" Ident)?Examples:
ng
import first.module (name as firstName);
import second.module (name as secondName);
export import std.string (join as stringJoin);Semantics
import m (aaa as bbb);binds local namebbbto exported symbolaaa.- Provenance records the canonical source module ID and original exported name separately from the local alias.
- Conflict checks are local-name based.
aaa as bbbconflicts with any other imported or local symbol namedbbbfrom a different source. - Re-importing the same original symbol from the same canonical source under the same local alias is idempotent.
- Diagnostics must report the local alias, original symbol, and canonical source module.
export import m (aaa as bbb);exportsbbbas this module's public symbol, while preserving provenance tom::aaa.- Module-qualified imports remain available and are preferred when many symbols from both modules are needed.
use impl Trait for Typecontinues to use module qualifiers and canonical module IDs. Symbol aliases do not create new trait or type identities.
Required Data
- AST import item structure with
exportedNameand optionallocalName. - Runtime/module artifact import provenance entries containing: local name, original exported name, canonical source module ID.
- Typechecker import metadata that distinguishes local alias from original export name for diagnostics and re-export artifact publication.
- ORGASM import metadata that can emit
CALL_IMPORTby original exported name while binding the local alias during compilation.
Acceptance Criteria
- Parser accepts
import m (aaa as bbb);and rejects malformed alias items. - STUPID and ORGASM both execute calls through aliased imported functions.
- Imported values, functions, types, traits, and impl evidence preserve original module provenance through aliases.
- Conflicts are detected by local name and include both source modules in the diagnostic.
export import m (aaa as bbb);re-exportsbbband downstream imports can usebbbwithout knowing the originalaaaname..ngoartifacts preserve alias metadata so source and bytecode modules expose the same public symbols.