Parent
Part of #272 (Glia import system)
Summary
Implement the Glia-script import path: (import "foo") resolves /lib/foo.glia from the merged FHS image, evals it in an isolated Env, and binds all top-level defs into the caller's Env with a foo/ prefix.
Scope
- Add
Expr::Import variant to crates/glia/src/expr.rs (match arm in analyze_list())
- Create
crates/glia/src/import.rs with resolution pipeline
- Resolution order: search
/lib/{name}.glia first, then /lib/{name}.wasm
- Eval imported
.glia in fresh Env (isolated — no leaking unprefixed defs)
- Bind results as
{module}/ prefixed names in caller's root frame via set_root()
- Support absolute
/ipfs/-prefixed paths: (import "/ipfs/QmHash.../foo.glia")
- Circular import detection via
HashSet<String> threaded through eval
Non-goals
- WASM imports (see sibling issue)
- Import caching / idempotent require (see TODOS.md)
- Guard clauses, namespace objects
Test cases (from design doc)
(import "utils") → utils/helper-fn callable
- Isolated eval: imported defs don't leak unprefixed into caller
- Module not found → error
- Empty .glia file → no bindings, no error
- Parse error in imported file → propagated error
- Nested path:
(import "math/core") → /lib/math/core.glia
- Circular import detection
/ipfs/-prefixed absolute import
Dependencies
- None (pure Glia-side work, uses existing WASI fs)
Parent
Part of #272 (Glia import system)
Summary
Implement the Glia-script import path:
(import "foo")resolves/lib/foo.gliafrom the merged FHS image, evals it in an isolated Env, and binds all top-level defs into the caller's Env with afoo/prefix.Scope
Expr::Importvariant tocrates/glia/src/expr.rs(match arm inanalyze_list())crates/glia/src/import.rswith resolution pipeline/lib/{name}.gliafirst, then/lib/{name}.wasm.gliain freshEnv(isolated — no leaking unprefixed defs){module}/prefixed names in caller's root frame viaset_root()/ipfs/-prefixed paths:(import "/ipfs/QmHash.../foo.glia")HashSet<String>threaded through evalNon-goals
Test cases (from design doc)
(import "utils")→utils/helper-fncallable(import "math/core")→/lib/math/core.glia/ipfs/-prefixed absolute importDependencies