Fork me on GitHub
#sci
<
2024-03-13
>
Ingy döt Net13:03:00

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?

borkdude13:03:51

unless you evaluate some expression which does that prior to the user's expression

Ingy döt Net14:03:33

Thanks. "you can't" is actually very helpful here 🙂

Ingy döt Net14:03:59

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...

Ingy döt Net15:03:45

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?