joyride 2022-05-29

NB: the evaluateCode() function now has moved to repl.evaluateCode(). (Though for now it is also available in its old place as well.) See updated API docs: https://calva.io/api/

I've added an example utility library for the Calva API here: https://github.com/BetterThanTomorrow/joyride/tree/master/examples/.joyride/scripts/z_joylib Including it as a text snippet here as well.

I'm currently in the woods. Will check tonight :-)

Reacted. You're close :)

@pez I think i got it, commented on Github my solution 🙂

Yep, I think @mauricio.szabo nailed it

I got the refer working, very similar to your solution, @mauricio.szabo. Mixed and match a bit from nbb and the example.

@pez I don't think you need apply here:

(apply gobject/getValueByKeys exports path)

But you need to pass an array in that case. For this you can use:

(.split module-name ".")

Isn't that what I am doing?

No, you are using str/split which returns a vector

So getValuesByKeys takes an array?

Cool. I'll try it. Then we should fix that where I picked this apply up as well, probably. 😃

apply also works, but my performance OCD was being triggered

(getValueByKeys obj (.split "foo" "."))

or (apply getValueByKeys obj (str/split "foo" ".")) both work

but the first one isn't converting things to and from js <> cljs

Yeah, I should change that :) In more recent code I discovered the array thing ;)

I also fixed a potential overwrite when requires might refer to something named the same as the module/namespace.

Oh interesting. Can you name an example of that?

Contrived:

["betterthantomorrow.calva" :as calva-ns :refer [v0]]
            ["betterthantomorrow.calva$v0" :as calva-js :refer [v0 repl ranges]]

clj-kondo seems to be picking it up somehow...

@pez So what is the problem with the above? Yes, you get refer conflicts, but that is expected?

["betterthantomorrow.calva$v0" :as calva-js :refer [v0 repl ranges]]
The v0 in refer here is unexpected, since you already went into the v0 property with $v0

You should probably write that as:

["betterthantomorrow.calva$v0" :as v0 :refer [repl ranges]]

Yes, it was contrived. What I mean is that something I refer from a module might be named the same as the module. (I might have a function named v0 in the v0 export.)