joyride

pez 2025-08-21T20:02:35.014739Z

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

pez 2025-08-22T07:25:06.412209Z

Thanks. Where should I be trying requiring-resolve?

pez 2025-08-22T07:50:31.731619Z

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

borkdude 2025-08-22T07:52:57.146979Z

just resolve should work

borkdude 2025-08-22T07:53:13.434149Z

(println (resolve 'a-ws-script/symbol-1))

borkdude 2025-08-22T07:53:53.554179Z

and maybe deref it to see the value

pez 2025-08-22T07:57:49.799469Z

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

pez 2025-08-22T07:59:24.492979Z

In 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?

pez 2025-08-22T08:01:27.771139Z

I can place them in joyride.core probably… They’re async after all.

borkdude 2025-08-22T08:01:38.304009Z

I did this because the signature isn't the same, e.g. promise based

pez 2025-08-22T08:03:02.427169Z

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.

borkdude 2025-08-21T20:16:07.794329Z

Isn't this just Gilardi scenario again? https://technomancy.us/143 Try (requiring-resolve '...)

borkdude 2025-08-21T20:17:30.465629Z

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