This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-27
Channels
- # aleph (1)
- # announcements (5)
- # babashka (13)
- # beginners (68)
- # brompton (7)
- # calva (10)
- # cider (1)
- # clara (15)
- # cljsrn (2)
- # clojure (63)
- # clojure-austin (1)
- # clojure-europe (44)
- # clojure-france (2)
- # clojure-nl (5)
- # clojure-norway (1)
- # clojure-poland (1)
- # clojure-uk (8)
- # clojurescript (8)
- # clojureverse-ops (7)
- # conjure (13)
- # core-async (27)
- # cryogen (10)
- # cursive (17)
- # datomic (13)
- # deps-new (1)
- # events (1)
- # fulcro (3)
- # gratitude (4)
- # helix (6)
- # honeysql (6)
- # introduce-yourself (1)
- # jobs (2)
- # malli (13)
- # meander (9)
- # music (1)
- # news-and-articles (2)
- # off-topic (8)
- # pedestal (1)
- # reitit (4)
- # sci (25)
- # shadow-cljs (13)
- # spacemacs (2)
- # tools-build (5)
- # tools-deps (20)
- # vscode (50)
- # xtdb (2)
just started playing w/ sci. so dang cool. anyone have an example handy for defining a new fn in an sci ctx from a .cljc file (so it should work in both CLJ and CLJS). there's a hurdle my brain isn't clearing somehow...
@cap10morgan you can use (sci/copy-var the-cljc-var sci-ns)
well, it doesn't exist as a var yet 🙂 I want to create in the sci ctx only
what I would do then is:
(defn my-new-fn [] ...)
and use copy-var
on that, or just use my-new-fn
directlyhopefully nothing! just mentioning in case the cljs side complicated anything 🙂
so, in this case I have user-supplied code at runtime that ideally would only become a fn bound to a var in sci, not in the outer clj(s) context
right. so you could do:
(def ctx (let [f (fn [] ...)] (sci/init {:namespaces {'my-sci-ns {'f f}}})))
ok... yep. and to add to an existing context... use merge-opts
?
:thumbsup: thanks!
@borkdude does merge-opts
add to the existing :namespaces
and :allow
values or do I need to do that myself first and pass in the whole new value for those?
(assuming I have :namespaces
and :allow
keys in my 2nd arg to it)
killer, thanks!
@borkdude if I wanted to replace some clojure.core fns w/ my own implementations in an sci ctx, would that be as simple as {:namespaces {'clojure.core map-of-my-replaced-syms-to-their-new-impls}}
?