tvix/eval: more granular evaluation (for repl purposes)
The nix repl behaves different than the tvix repl.
The Tvix repl currently expects the passed Nix code to be a somewhat self-contained Nix program.
The Nix repl allows you to do some more "back and forth" with the evaluator, essentially mutating variables in a per-session scope.
We currently have no infrastructure to run some code with the evaluator, and then run some more code.
This would however be helpful for this usecase, as well as enabling tab completion.
Evaluation::evaluate()
currently consumes self, and returns an Evaluation result.
I propose to change this to take &mut self, and having some notion of a toplevel scope accessible as attributes, allowing more dialogues to happen with the evaluator and something interactive driving it.
evaluate
doesn't need to and should not know about this. All the nix repl has is extra syntax (that wouldn't parse as a Nix expression) to bind something in the global scope. All that's necessary is to add the returnedValue
to the globals of the evaluator struct after some special command.sterni at 2024-01-18T10·59+00
claim
aspen at 2024-07-04T16·29+00
https://cl.tvl.fyi/c/depot/+/11954
flokli at 2024-07-05T16·32+00
- flokli closed this issue at 2024-07-05T16·47+00