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

[#65] Make REPL vars available #66

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/try_clojerl/repl.clje
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
(require '[clojure.repl :refer (source apropos dir pst doc find-doc)])
(require '[clojure.pprint :refer (pp pprint)])
(require '[try-clojerl.tutorial :as tutorial :refer (next-step prev-step)])
(push-thread-bindings {#'*1 nil
#'*2 nil
#'*3 nil
#'*e nil
#'*stacktrace nil})
(tutorial/init)))

(defn eval-string [s]
Expand All @@ -66,8 +71,14 @@
(let [group-leader (erlang/group_leader)
res (try
(erlang/group_leader (maps/get :pid out) (erlang/self))
(-> s read-string eval pr-str)
(catch _ e
(let [value (-> s read-string eval)]
(set! *3 *2)
(set! *2 *1)
(set! *1 value)
(pr-str value))
(catch _ e :stack st
(set! *e e)
(set! *stacktrace st)
(.write *err* (str "Error: " (pr-str e)))
"")
(finally
Expand Down