sci

Ingy döt Net 2024-03-13T13:51:00.787169Z

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?

borkdude 2024-03-13T13:56:31.348389Z

you can't

borkdude 2024-03-13T13:56:51.192179Z

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

Ingy döt Net 2024-03-13T13:59:22.996719Z

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.

Ingy döt Net 2024-03-13T14:00:33.437529Z

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

Ingy döt Net 2024-03-13T14:38:59.539599Z

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 Net 2024-03-13T15:58:45.055229Z

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?