Imports
Imports
Thagore supports direct imports, alias imports, from imports, relative imports, and include all. Resolution is deterministic; ambiguity is only possible at use sites when multiple include all imports expose the same symbol.
Import forms
Import a module and use its name directly
import std.math
func main() -> i32: return 0Import with an alias
import std.math as math
func main() -> i32: if (math.PI > 3.14): return 0 return 1Import specific symbols
from math import sqrt, abs as absoluteImport everything from a module
import src.utils include allRelative imports
from . import utilsfrom .. import corefrom .utils import helper as helper_aliasfrom . import shared include allModule sources
The current resolver recognizes these sources:
| Source | Example |
|---|---|
| Stdlib | import std.math |
| Dependency include dirs | import http |
| Project modules | import src.build.compiler as compiler |
| Relative modules | from . import utils |
Resolution order
The active resolver uses this order:
- relative imports like
./and../ - single-name imports resolved as stdlib, then include dirs, then project
src/ - dotted project imports such as
src.build.compiler
Examples:
import lib.fs as fsimport src.project.manifest as manifestfrom .utils import helperInclude-all conflicts
include all is resolved lazily. The import itself is accepted, and ambiguity is reported when you use the colliding name.
Conceptually:
import math include allimport vec include allIf both modules export len, an unqualified len(...) is rejected and you must write a qualified reference instead.
Practical guidance
- Prefer explicit imports in application code.
- Use aliases for frequently referenced modules such as
std.math as math. - Reserve
include allfor small local modules where conflicts are easy to manage.