Skip to content

interactive: import/export in the IR#749

Open
frankmcsherry wants to merge 1 commit into
master-nextfrom
pr-import-export
Open

interactive: import/export in the IR#749
frankmcsherry wants to merge 1 commit into
master-nextfrom
pr-import-export

Conversation

@frankmcsherry

Copy link
Copy Markdown
Member

Adds import / export to the DD IR: generalizes the single result
output to a named export list, and adds Node::Import for named external
traces.

What

  • Surface: export "name" = expr; and import "name";. result expr;
    becomes sugar for export "$result" = expr;.
  • IR: Program.export: Vec<(String, Id)> (was a single result id);
    new Node::Import { name }, resolved by shape against a registry.
  • Threaded through lower, both parsers, explain, and the
    ddir_vec / ddir_col / dump_explain examples.

Why

Foundation for multi-output programs and named-trace inputs (the upcoming
live server resolves imports against its registry); the explanation rewrite
and a future optimizer also build on the export list.

Review notes

  • export is fully functional standalone — the lib renderers use it.
  • import is a declaration with no resolver in the lib: only a registry
    binds it, so ddir_vec/ddir_col panic! on a Node::Import and no
    example uses one yet. Compiler-IR "unresolved extern" pattern; the
    resolver lands with the server. Lib + examples only — no server crate.

@frankmcsherry frankmcsherry left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments for Claude about things to tighten.

Comment thread interactive/src/parse/applicative.rs Outdated
Comment thread interactive/src/parse/mod.rs Outdated
Comment thread interactive/src/parse/pipe.rs Outdated
Comment thread interactive/src/explain.rs
Comment thread interactive/src/explain.rs
Comment thread interactive/src/explain.rs Outdated
Comment thread interactive/src/lib.rs Outdated
Comment thread interactive/src/lib.rs Outdated
Comment thread interactive/src/lower.rs Outdated
Comment thread interactive/src/lower.rs Outdated
Add `import "name"` and `export "name" = expr` to the IR and both surface
syntaxes, and remove the `result` statement: `export` is now the sole way to
declare a program output, and only at the root scope. `Program.export` is a
named list (was a single result id); `Node::Import` resolves against a
registry at install time.

`Node::Import` is a stub outside the server (the example renderers panic on
it, no example uses it); the intended end-state is one named-source substrate
that subsumes `Input(usize)` — there should not be two ways to bring in a
source. `survey_sources` (was `count_inputs`) returns both kinds until that
cutover.

Threaded through lower, both parsers, explain, and the ddir_vec/ddir_col/
dump_explain examples; example programs now use `export "result" = …`. The
string lexer is read-until-quote (no escapes — names don't use them).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant