This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-15
Channels
- # aleph (2)
- # babashka (35)
- # beginners (31)
- # biff (6)
- # calva (6)
- # cider (5)
- # clojure (61)
- # clojure-android (1)
- # clojure-dev (12)
- # clojure-europe (22)
- # clojure-norway (7)
- # clojure-uk (4)
- # clojurescript (19)
- # datomic (5)
- # events (3)
- # fulcro (15)
- # graalvm (41)
- # guix (2)
- # honeysql (2)
- # hoplon (8)
- # hyperfiddle (10)
- # jobs (1)
- # off-topic (29)
- # overtone (5)
- # podcasts-discuss (1)
- # remote-jobs (1)
- # sci (30)
- # shadow-cljs (186)
- # specter (2)
- # squint (22)
What do I need to do to add slurp
to eval-string*
's context?
(sci/init {:namespaces {'clojure.core {'slurp (sci/copy-var slurp (sci/create-ns 'clojure.core))}}})
That worked. I forgot to say thanks...
I looked at the bb main code that sets up the context for sci eval but it is rather massive.
What gets refered into the user ns automatically ?
It seems like I can copy-var things into the clojure.core ns and they are available in user at runtime
$ bb -e '(->> *ns* ns-refers vals (map var-get) (map type) (filter type) (map str) (map #(str/replace % #".* (.*?)(\$.*|$)" "$1")) sort distinct pprint)'
("babashka.impl.clojure.core"
"babashka.impl.pprint"
"babashka.main"
"clojure.core"
"clojure.lang.AFunction"
"clojure.lang.LineNumberingPushbackReader"
"clojure.lang.MultiFn"
"clojure.lang.PersistentArrayMap"
"clojure.lang.PersistentList"
"clojure.lang.Ref"
"clojure.lang.Var"
"java.io.OutputStreamWriter"
"java.io.PrintWriter"
"java.lang.Boolean"
"java.lang.String"
"sci.addons.future"
"sci.impl.core_protocols"
"sci.impl.deftype"
"sci.impl.doseq_macro"
"sci.impl.fns"
"sci.impl.for_macro"
"sci.impl.hierarchies"
""
"sci.impl.multimethods"
"sci.impl.namespaces"
"sci.impl.protocols"
"sci.impl.proxy"
"sci.impl.read"
"sci.impl.records"
"sci.impl.reify"
"sci.impl.types"
"sci.impl.utils"
"sci.impl.vars"
"sci.impl.vars.SciUnbound"
"sci.lang.Namespace")
is a glimpse of which vars get somehow refered into the user ns.
does bb copy-var all the vars into clojure.core
or ...?
sorry I can't phrase this better
sure I get that
I'm trying to figure out how the vars from those namespaces made it into user
's ns-refers
I could accomplish that by doing a copy-var from every interesting ns into clojure.core but that feels odd
I just want to know if you (bb) copy-var each var into clojure.core
Or are there other namespaces that also get auto referred
I looked at babashka.main before even asking here, but like I said it's quite massive
tbh I never use this function so I had to look up the docstring what it even does ;)
$ bb -e "(map ns-name (distinct (map :ns (map meta (vals (ns-refers 'user))))))"
(clojure.core clojure.repl clojure.pprint)
got it
iirc ns-map == ns-publics + ns-refers
anyway your bb
cmd above is exactly what I was curious about. thanks.