Phase −1.C of docs/archive/bootstrap-plan.html. Lets a Silicon source file pull
in other Silicon files at compile time.
Scoped down by ADR-0024 (module/component system, implemented). Inside a project (an
sgl.toml-rooted component)@useis no longer needed for intra-component code: all.sifiles in a module directory are auto-included, and other modules are called asmod::name. A path@usethat points at a same-component file is now redundant — it emits aW-USE-REDUNDANTdeprecation warning andsgl fixremoves it. The bare-name stdlib include (@use 'io';) is retained verbatim — that is the one surviving role at v1.0. Cross-component dependencies use the import line\\ @use name [as alias];(see ADR-0024). Everything below still describes the underlying concatenation engine, which now also powers stdlib resolution for the component assembler. Standalone files compiled outside a project keep the classic@use-only behaviour described here.
@use 'helper.si';
@use './lib/strings.si';
@use '/abs/path/to/file.si';
- Relative paths resolve from the including file's directory (not the entry's).
- Absolute paths are honoured as-is.
- The trailing
;is required (it is the statement terminator the rest of the language uses). - Inside a
#comment,@useis not followed:# @use 'x.si';is just a comment.
Per the bootstrap plan and cleanup plan, the simplest possible rule:
- Textual concatenation in dependency order. Each included file's source is emitted before the includer's. Everything ends up in one global namespace as if the user had concatenated by hand.
- Cycle detection. Including A from B and B from A throws a clear error showing the cycle.
- Deduplication. The same file referenced multiple times is emitted only once (first sighting wins).
- No namespacing yet. Visibility / scoping is deliberately deferred to post-Stage-3. Names from included files appear in the global scope.
# helper.si
\\ add (Int, Int) -> Int
@fn add a, b := { a + b };
# main.si
@use 'helper.si';
sum := { add(1, 2) };
Compiling main.si produces a WAT module that contains $add, $sum, and
the top-level add(1, 2) call inside $__start.
src/modules/useResolver.ts is a pre-parse text preprocessor. It runs
before the parser sees the source so the grammar stays unchanged (per CLAUDE.md).
The CLI (src/sigil_cli.ts) calls it before parsing.
Tested by src/modules/useResolver.test.ts (unit) and
src/modules/useResolver.integration.test.ts (full pipeline).