scheme
scheme copied to clipboard
Repl doesn't persist definitions
The Repl doesn't remember definitions:
Repl> (define myid (lambda (x) x))
myid
Repl> (myid 1)
Error Unbound Variable: myid
This works:
Repl> (begin (define myid (lambda (x) x)) (myid 1))
1
The cute trick here would be to capture the interpreter state just after evaluating each expression in Eval.evalBody
(crucially, including the extended environment) and to return to Repl.process
both the result of evaluating the current expression, and a suspended computation to run on the /next/ expression.
Wow. This doesn't sound good. I tested the original WYAS code, and it works fine. I guess I'll use that project then.
Yes, it's a bit unfortunate, I need to return to this problem when I get some time.
My thinking on the issue is that using ReaderT
evaluator makes the tutorial a bit more understandable and accessible. For that, we lose a simple way to persist definitions: there's just no state to update!
For the evaluator, there must be a way to run eval, e -> a
, capture that a
, stick it in the e
, then run the next line with the appended e
.