scheme icon indicating copy to clipboard operation
scheme copied to clipboard

Repl doesn't persist definitions

Open lambdageek opened this issue 8 years ago • 3 comments

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

lambdageek avatar Feb 14 '17 03:02 lambdageek

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.

lambdageek avatar Feb 14 '17 04:02 lambdageek

Wow. This doesn't sound good. I tested the original WYAS code, and it works fine. I guess I'll use that project then.

timmyjose avatar Oct 25 '21 07:10 timmyjose

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.

adamwespiser avatar Nov 05 '21 18:11 adamwespiser