When you create a namespace in a sci evaluation, all of the public symbols from clojure.core are referred as it should be.
I've been merging vars into clojure.core from another ns so they will also be "auto-referred".
But that's become problematic, and I'd like to specify that other ns as something to be additionally auto-referred.
How can I do that in my sci context init?
you can't
unless you evaluate some expression which does that prior to the user's expression
OK, another thing I can do is copy-ns clojure.core to some other ns so that I can get at stuff that the merge replaces. Or just copy the specific vars rather than the whole thing is probably better.
Thanks. "you can't" is actually very helpful here 🙂
hmmm. It's a bit tricky because I want to get at this var:
https://github.com/babashka/sci/blob/a39073922c10638f6a5afd0ade139d6bcde24535/src/sci/impl/namespaces.cljc#L1332
is there a simple way to do that?
Basically I'm trying to define my own eager version of for that calls the for in sci...
Given this in ys.ys
(defmacro for [bindings & body]
`(do
(doall (_for [~@bindings] (do ~@body)))
nil))
I'm trying this in my sci setup:
(sci/intern @ys/sci-ctx 'clojure.core '_for
(sci/resolve @ys/sci-ctx 'clojure.core/for))
(sci/intern @ys/sci-ctx 'clojure.core 'for
(sci/resolve @ys/sci-ctx 'ys.for/for))
but getting
Syntax error macroexpanding at (runtime.clj:108:1).
Execution error (ExceptionInfo) at sci.lang.Var/bindRoot (lang.cljc:112).
Built-in var #'clojure.core/for is read-only.
is there a way to pull this off?