cgrand / cljs-js-repl

Upgradable self hosted clojurescript repl
21 stars 2 forks source link

async `eval` #2

Closed cgrand closed 7 years ago

cgrand commented 7 years ago

eval in self-hosted cljs has an async api (a callback is called with the result or error from the evaluation). Right now it's a provision (in case some IO for example has to be made during eval).

The problem is that cljs-js-repl makes intensive use of dynamic variables. They are set when eval is called, they can ve set again when the callback is called but not in between (again it's not a problem currently because eval impl is sync in Lumo and Planck, so there's no in-between.

cgrand commented 7 years ago

At first I thought CLJS would have to solve its dynvar issue first.

Then I thought the dynvar handling could be abstracted so that CLJS would not commit to a dynvar impl yet.

Now I realize that the only parts of "in-between" where having dynvars set is when running code, that is when *eval-fn* (for evaluating js code) is called. So it just need to be wrapped in function that set dynvars!