@borkdude I am trying to implement load-file and only almost get it to work. This is what I currently have
• https://github.com/BetterThanTomorrow/joyride/compare/master...0ab217c6e1e69164d69589d749dc6c820de05032
(It’s in a branch load-file, but I used the SHA here because I may push something completely different in my desperation, lol)
It almost works because I can do things like
(load-file ".joyride/scripts/a_ws_script.cljs")
and it seems to do the things I expect it to do. Like side effects happen, and symbols are defined and such. And also side effects happen as I expect. The file looks like so:
(ns a-ws-script
(:require [promesa.core :as p]
["vscode" :as vscode]))
(p/do!
(vscode/window.showInformationMessage "Hello" "OK")
(p/delay 2000))
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(def symbol-1 :a-ws-script)
symbol-1
I can also do:
(p/let [r (load-file ".joyride/scripts/a_ws_script.cljs")]
(println r))
And it seems to work. Printing :a-ws-script
However, if I try to do this in a fresh repl:
(p/let [r (load-file ".joyride/scripts/a_ws_script.cljs")]
(println a-ws-script/symbol-1))
; Could not resolve symbol: a-ws-script/symbol-1
And joyride-load-file isn’t even called, afaict. (None of the printlns in it happen.)
I’ve peeked at how nbb does it, but it is a lot, and I think since Joyride isn’t as async as nbb, most of that isn’t needed in Joyride?
Anyway, I’m stuck and out of luck and ideas.Thanks. Where should I be trying requiring-resolve?
Ah, so now I get it. (Maybe)
(p/let [r (load-file ".joyride/scripts/a_ws_script.cljs")]
(println a-ws-script/symbol-1))
Isn’t supposed to work?
If so, maybe my load-file is fine. Works great using sci/eval-string+, btw.
(I don’t think we have requiring-resolve in Joyrdie yet. But that’s cool as long as load-file works for loading files.)just resolve should work
(println (resolve 'a-ws-script/symbol-1))
and maybe deref it to see the value
Thanks. Works!
(p/let [r (load-file ".joyride/scripts/a_ws_script.cljs")]
(println (resolve 'a-ws-script/symbol-1))
(println @(resolve 'a-ws-script/symbol-1)))
=> #<Promise [pending:50]
#'a-ws-script/symbol-1
:a-ws-scriptIn nbb I notice that you have placed load-file in nbb.core. Because reasons I want it to be in clojure.core for Joyride. Bad idea?
I can place them in joyride.core probably… They’re async after all.
I did this because the signature isn't the same, e.g. promise based
Yeah, makes sense. It’s mostly that Copilot is always trying to load files using load-file, but I will try if I can include instructions directing at joyride.core/load-file.
Isn't this just Gilardi scenario again?
https://technomancy.us/143
Try (requiring-resolve '...)
For this thing: https://github.com/BetterThanTomorrow/joyride/compare/master...0ab217c6e1e69164d69589d749dc6c820de05032#diff-858eb3915f07675fe6b38ba5c8432c52f87b9c63d7eb52af80e200d4b5c4692eR108-R117
you can use sci/eval-string+ instead, it will also return the namespace