This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-16
Channels
- # announcements (7)
- # babashka (1)
- # beginners (125)
- # bristol-clojurians (4)
- # calva (49)
- # cider (10)
- # cljs-dev (3)
- # clojure (102)
- # clojure-berlin (3)
- # clojure-czech (4)
- # clojure-europe (84)
- # clojure-france (29)
- # clojure-italy (2)
- # clojure-nl (26)
- # clojure-norway (5)
- # clojure-spec (4)
- # clojure-sweden (4)
- # clojure-uk (50)
- # clojurescript (3)
- # community-development (2)
- # conjure (19)
- # cursive (9)
- # datascript (4)
- # datomic (33)
- # fulcro (4)
- # off-topic (26)
- # parinfer (10)
- # pedestal (4)
- # quil (8)
- # re-frame (1)
- # reagent (20)
- # remote-jobs (5)
- # reveal (53)
- # sci (10)
- # shadow-cljs (37)
- # spacemacs (6)
- # sql (25)
- # tools-deps (24)
- # vrac (2)
- # xtdb (10)
IDeref / IAtom now implementable in user code on sci master: https://twitter.com/borkdude/status/1306206133539999745
Hi I have a little question regarding eval-form. It's said to bind sci/ns
with sci/binding
. I have try the following which works:
(def program
'(let [current-ns (-> *ns* str symbol)]
(ns foo)
(defn bar [x] (inc x))
(in-ns current-ns)
(require 'foo)
(foo/bar 1)))
(def env (sci/init {}))
(sci/binding [sci/ns sci/ns]
(sci/eval-form env program))
Is this the proper use of the binding requirement? sci.impl.interpreter/eval-string*
goes with something like:
(vars/with-bindings {vars/current-ns @vars/current-ns}
the reason for the binding is the same as in clojure: set! is only allowed when there is already a thread-local binding
@jeremys ns switches aren't supported in let forms, only top level or in top-level do:
(require '[sci.core :as sci])
(def program
'(do (ns foo)
(defn bar [x] (inc x))
(ns user)
(require 'foo)
(foo/bar 1)))
(def env (sci/init {}))
(sci/binding [sci/ns sci/ns]
(prn (sci/eval-form env program)))
Note that that doesn't work in normal Clojure either:
(let [current-ns (-> *ns* str symbol)]
(prn current-ns)
(ns foo)
(defn bar [x] (inc x))
(in-ns current-ns)
(require 'foo)
((resolve 'foo/bar) 1))