You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*** Inside the sci runtime*** (binding [clojure-ns/*var* true] clojure-ns/*var* )
Getting error: Can't dynamically bind non-dynamic var ***
expected behavior
No error
I checked the code under vars.cljc, I think its not possible to do this as the dynamic vars inside the interpreter are managed completely differently, but please let me know if there's a way to do it. What I'm looking for is a way to interop from sci to the clojure(script) code transparently with common dynamic vars.
Sponsor
The text was updated successfully, but these errors were encountered:
You're right, SCI has its own way of dealing with dynamic vars. It is decoupled from Clojure since any Clojure dialect has a different way of dealing with vars and also because SCI's context is fully isolated from the host: you don't want to have any Clojure vars in there which could cause safety issues.
To deal with this case, what I've done in several projects, including babashka, is wrap functions that need to see the binding from the host:
version
{:sha "75117e6139d0026d4dd035932862134a21c2c41a"}
platform
Mac V.11.2.3
problem
When using sci/copy-ns of a namespace that contains dynamic vars, the dynamic vars are not working in the interpreter.
repro
(ns clojure-ns) (def ^:dynamic *var*)
*** Start a sci runtime with***
(sci/init {:namespaces {'clojure-ns (sci/copy-ns clojure-ns (sci/create-ns 'clojure-ns nil))} :features #{:clj :cljs}})
*** Inside the sci runtime***
(binding [clojure-ns/*var* true] clojure-ns/*var* )
Getting error: Can't dynamically bind non-dynamic var ***
expected behavior
No error
I checked the code under vars.cljc, I think its not possible to do this as the dynamic vars inside the interpreter are managed completely differently, but please let me know if there's a way to do it. What I'm looking for is a way to interop from sci to the clojure(script) code transparently with common dynamic vars.
Sponsor
The text was updated successfully, but these errors were encountered: