Modules
Jiang currently uses source files as modules. Imports connect source files, and imported APIs stay under a module namespace instead of being flattened into the current file.
File Imports
Section titled “File Imports”The default module name comes from the file name. After importing math.jiang, access public
declarations through math.Name:
Import Aliases
Section titled “Import Aliases”Use an alias when the file name is not the module name you want:
The alias names the target module namespace. It does not flatten imported declarations into the current module.
File Paths
Section titled “File Paths”A quoted import is a file path import:
File paths are interpreted relative to the importing source file. Write the full path; imports do
not automatically add .jiang or search for a directory entry.
Quoted file imports are only for files inside the current package. To import another package, declare
it in package.jiang and use an unquoted package import.
Visibility
Section titled “Visibility”Declarations that should be visible to other modules use public:
Declarations without public are module-local.
Extensions follow the same import visibility rule. An extension in another module does not become
active just because the target type is visible; the consumer must import the module that defines the
extension. Extensions meant for other modules should be written as public extend.
public const is also part of the module API. Consumers can read scalar constants and fields on
const structs through the module namespace:
Re-exports
Section titled “Re-exports”public alias name = import ...; imports a module for local use and re-exports that namespace as part of the
current module API:
This does not flatten imported declarations:
Use alias to give a type or an existing symbol another name:
If the right-hand side resolves to an existing namespace, type, value, or member symbol, the alias is bound in that same name domain. If it does not resolve to an existing symbol, the right-hand side is treated as type syntax and must be a valid type.
public alias re-exports a public symbol through the current module API:
For a function target, the alias keeps the target’s public overload family. Calls use normal overload resolution in the target namespace, and private functions with the same name are not re-exported.