Skip to content

[WIP] Symbol Table Abstraction#125

Open
iwillspeak wants to merge 11 commits into
feature/workspacesfrom
claude/file-collections-imports-FhgTa
Open

[WIP] Symbol Table Abstraction#125
iwillspeak wants to merge 11 commits into
feature/workspacesfrom
claude/file-collections-imports-FhgTa

Conversation

@iwillspeak

Copy link
Copy Markdown
Owner

Design doc 05 assumed a compiler-level Workspace wrapping SourceRegistry. The actual implementation removed SourceRegistry and made SyntaxRoot<'a> a self-contained value that carries its own TextDocument.

Add doc 06 which:

  • Collapses the three-layer model to two (parse → compilation)
  • Describes Workspace as an LSP-layer actor only (WorkspaceAgent)
  • Defines FileCollection as a plain list of SyntaxRoot
  • Specifies Scope as the explicit input/output of binder entry points, enabling ergonomic REPL chaining without re-compiling from scratch
  • Proposes SymbolTable (Definition, Reference, Exports, Imports) on BoundSyntaxTree to model the semantic content of a bound program, as the foundation for LSP hover, go-to-definition, and find-references

Design doc 05 assumed a compiler-level Workspace wrapping SourceRegistry.
The actual implementation removed SourceRegistry and made SyntaxRoot<'a>
a self-contained value that carries its own TextDocument.

Add doc 06 which:
 - Collapses the three-layer model to two (parse → compilation)
 - Describes Workspace as an LSP-layer actor only (WorkspaceAgent)
 - Defines FileCollection as a plain list of SyntaxRoot<Program>
 - Specifies Scope as the explicit input/output of binder entry points,
   enabling ergonomic REPL chaining without re-compiling from scratch
 - Proposes SymbolTable (Definition, Reference, Exports, Imports) on
   BoundSyntaxTree to model the semantic content of a bound program,
   as the foundation for LSP hover, go-to-definition, and find-references

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@iwillspeak iwillspeak changed the title docs: Rework workspace design doc to reflect isolated syntax trees [WIP] Symbol Table Abstraction May 4, 2026
claude and others added 2 commits May 4, 2026 07:50
Ensures Claude Code reads the same agent configuration as other agents,
including the build/test workflows, code style conventions, and skills.

https://claude.ai/code/session_01Ue7rpYvC4DBAQLGCQMKagp
…nment)

- Replace `Scope = Map<string, StorageRef>` shim in Environments.fs with a
  proper `Scope` record holding StxEnv, Bindings, Libs, and Macros; add
  `Scope.empty` and `Scope.ofLibraries` constructors.
- Rework `Binder.bindProgram` / `bindScript` to accept and return `Scope`,
  threading output bindings and macros back to callers for REPL chaining.
- Add `FileCollection` type alias and `FileCollection.ofPaths` / `ofRoots`
  helpers in Parse.fs; use `ofPaths` in `Compiler.compileFiles`.
- Update `Compiler.compile` to build an initial `Scope` from library
  signatures and builtin macros instead of the old `Environments` shim API.
- Update `BinderTests` and `LowerTests` to use the new `Scope`-based API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@iwillspeak iwillspeak force-pushed the claude/file-collections-imports-FhgTa branch from c5dec16 to 60eca14 Compare May 4, 2026 07:52
let missing =
{ Doc = { Id = DocId.Synthetic; Path = "missing"; LineStarts = [] }
{ Doc =
{ Id = DocId.Synthetic

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Can we get rid of DocId now

let macros, stxEnv = Builtins.loadBuiltinMacroEnv baseScope.StxEnv

let inputScope =
{ baseScope with

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I feel like this Scope with stuff could be cleaner.

I also feel that the loadBuiltinMacro should perhaps just take and return a scope.

iwillspeak and others added 3 commits May 4, 2026 09:06
Add a `Compilation` record type that carries the lowered bound tree,
output scope, and emit context (Target, RefTypes, Options) so that
binding and emission can be decoupled.

- `Compilation.create` resolves references, builds the initial scope,
  binds, and lowers — returning a `Compilation` without touching streams.
- `Compilation.createDerived` does the same but inherits Target/RefTypes/
  Options from a previous step and uses its OutputScope as the input,
  enabling each REPL line to see all prior top-level definitions.
- `Compilation.emit` writes the lowered tree to a stream; skips emission
  when the bound tree has errors.
- `Compilation.compile` becomes a one-liner over create + emit, so all
  existing call sites remain unchanged.
- `Eval.evalWithPrev` uses create/createDerived/emit to evaluate a script
  and returns the resulting `Compilation` for the caller to thread forward.
- `Repl.runRepl` now maintains `mutable state: Compilation option` and
  folds each input through `evalWithPrev`, accumulating scope across lines.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Documents aren't persisted into stores any longer. The DocID isn't
neeeded.
@iwillspeak iwillspeak requested a review from Copilot May 4, 2026 15:33
iwillspeak added 4 commits May 4, 2026 16:33
REPL needs to know about incrementing the program index to give each
successive REPL step a unique name. This doesn't need to be something
that the compiler worries about though.

Fixup dispose on eval's load context so that we do clean up assemblies
once we've done with them. This will be important for Blazor.
Include the step in the prompt.
@iwillspeak iwillspeak marked this pull request as ready for review May 4, 2026 19:50
Replace the confusing `Compilation.create`/`createChained` pair with two
explicit primitives: `Compilation.bind` (returns `BindResult`, no emission)
and `Compilation.compile` (bind + emit in one step). The `compile` function
takes a `CompileContext` DU — either `Fresh options` for a standalone build
or `Chained(prevOutput, programName)` for REPL scope chaining — making the
two modes of use a first-class part of the signature rather than separate
function names. `CompileResult` is removed (it was unused outside the module).

Co-Authored-By: Claude Sonnet 4.6 <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.

2 participants