Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repl doesn't persist definitions #22

Open
lambdageek opened this issue Feb 14, 2017 · 3 comments
Open

Repl doesn't persist definitions #22

lambdageek opened this issue Feb 14, 2017 · 3 comments

Comments

@lambdageek
Copy link
Contributor

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
Copy link
Contributor Author

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.

@timmyjose
Copy link

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

@adamwespiser
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants