Appendix E: Module System (Future)¶
Current State: All standard library functions and traits are automatically in scope.
Future Design: A module system for organizing code and managing namespaces.
Proposed Syntax:
// Import entire module (using :: prefix)
::std::math use
// Import specific items
::std::collections::HashMap use
// Import with alias - Option 1: Inline alias
::std::io::File ::F as use
// Import with alias - Option 2: Separate alias operator
::std::io::File ::F use_as
// Import with alias - Option 3: Block syntax
{ ::std::io::File ::F as } use
// Export from current module
::Point ::geometry export
::distance ::geometry export
// Module declaration
::my_module module {
// Module contents
}
Module Resolution:
- Standard library:
::std::<module>::<item> - User modules: Relative to current file
- Third-party: Package manager integration (future)
Benefits:
- Clean namespaces
- Explicit dependencies
- Code organization
- Faster compilation (selective imports)