Skip to content

Commit

Permalink
babashka/babashka#565: don't pass use option via ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Sep 6, 2020
1 parent 8c154a5 commit 120175f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/sci/impl/interpreter.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,12 @@
env))

(defn handle-require-libspec
[ctx libspec]
[ctx libspec use?]
(let [{:keys [:lib-name :reload] :as parsed-libspec} (parse-libspec libspec)
env* (:env ctx)
env @env* ;; NOTE: loading namespaces is not (yet) thread-safe
cnn (vars/current-ns-name)
namespaces (get env :namespaces)
use? (:sci.impl/use ctx)
ctx (dissoc ctx :sci.impl/use)
uberscript (:uberscript ctx)
reload* (or reload uberscript)]
(if-let [the-loaded-ns (when-not reload* (get namespaces lib-name))]
Expand Down Expand Up @@ -247,9 +245,8 @@
(throw (new #?(:clj Exception :cljs js/Error)
(str "Could not find namespace " lib-name ".")))))))

(defn eval-require
[ctx & args]
#_(prn "eval require" args)
(defn eval-require*
[ctx args use?]
(loop [libspecs []
current-libspec nil
args args]
Expand All @@ -272,13 +269,17 @@
(next args))))
(let [libspecs (cond-> libspecs
current-libspec (conj current-libspec))]
(run! #(handle-require-libspec ctx %) libspecs)))))
(run! #(handle-require-libspec ctx % use?) libspecs)))))

(defn eval-require
[ctx & args]
(eval-require* ctx args false))

(vreset! utils/eval-require-state eval-require)

(defn eval-use
[ctx & args]
(apply eval-require (assoc ctx :sci.impl/use true) args))
(eval-require* ctx args true))

(vreset! utils/eval-use-state eval-use)

Expand Down

0 comments on commit 120175f

Please sign in to comment.