Module System Redesign Overview
The module system work is intentionally split into several implementation-sized designs. The old single document mixed source imports, type metadata, native modules, bytecode persistence, and standard library layout; that made it easy to create Issues with unclear scope.
Split Documents
Implement the module-system-specific work in this local dependency order. These local numbers are not global issue-order numbers:
- Module Artifact And Typechecker Integration
- Native Module Artifacts
- Bytecode Module Loading
- Standard Library Modularization
Overall Goal
Replace the early STUPID-era module loader with a single module system that works consistently across parsing, type checking, STUPID execution, ORGASM compilation, bytecode loading, native libraries, and the standard library.
The complete system must eventually support:
- Modular standard library imports such as
import std.prelude (*). - Facade modules with explicit re-exports such as
export import std.string (*);. - Conflict-safe imports using module-qualified access (
import x as xmod; xmod.name(...)). - Future symbol-level aliases as a separate extension: Symbol Import Aliases.
- File-based
.ngsource modules. - Native module interop for C++-registered libraries.
- ORGASM bytecode modules loaded from compiled
.ngoartifacts. - Compatibility between
.ngsource modules and.ngobytecode modules. NG_MODULE_PATHsearch path compatibility.- Cross-module exported traits and impl evidence.
Current Problems
FileBasedExternalModuleLoaderis source-file-first and tightly coupled to parsing.- Type checking has partial import behavior and can fall back to
Untypedfor unresolved imports. - STUPID runtime modules, typechecker module artifacts, and ORGASM bytecode modules carry different metadata.
- Native functions are registered through runtime hooks and are not represented as first-class module artifacts.
- ORGASM can compile imported source modules, but there is no stable
.ngoartifact format or loader priority.
Non-Goal
This overview is not the implementation issue. Use the split documents above when creating concrete Issues.