sci

Ory Band 2022-09-18T11:33:46.209139Z

Hi. I have an issue evaling a sci form in malil, thought it might be relevant to ask here as well: https://clojurians.slack.com/archives/CLDK6MFMK/p1663500554062529

borkdude 2022-09-18T11:34:30.675449Z

if something is unresolved in SCI then you have to add it to the context

borkdude 2022-09-18T11:35:28.527169Z

not sure how malli lets you do that. I'll have a look

🙏 1
Ory Band 2022-09-18T11:36:44.170049Z

i also tried calling the java fn directly without the wrapping clojure fn. same results ie could not resolve Runtime/..

borkdude 2022-09-18T11:37:33.285409Z

so it seems that you can provide options to the SCI context somehow: https://github.com/metosin/malli/blob/56533336ceb742e63a84d5c1c13095c0ef5383ef/src/malli/sci.cljc#L12

Ory Band 2022-09-18T11:39:31.318669Z

but what should i pass?

borkdude 2022-09-18T11:39:38.941209Z

yeah. I don't see how as a malli user you can provide extra options there. Better ask in #malli or to @ikitommi here

🙏 1
Ory Band 2022-09-18T11:42:11.200529Z

wait, unrelated to malli, what is sci missing? the Runtime namespace? the error is still unclear

borkdude 2022-09-18T11:44:21.678789Z

if you want to expose your get-cpus function in SCI, you can do that as follows:

(def ctx (sci/init {:namespaces {'user {'get-cpus get-cpus}}}))
(sci/eval-string* ctx "(get-cpus)")

Ory Band 2022-09-18T11:44:22.942929Z

it needs an`:import` instead of :require

borkdude 2022-09-18T11:45:30.114479Z

you don't get access to host classes by default, they have to be explicitly brought in:

{:classes {'Runtime Runtime}}