joyride

pez 2022-05-29T07:12:25.079179Z

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/

pez 2022-05-29T09:16:31.970899Z

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.

pez 2022-05-29T11:46:33.104179Z

I need some help here, @borkdude ! 😃 https://github.com/BetterThanTomorrow/joyride/pull/72

borkdude 2022-05-29T12:50:36.409229Z

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

borkdude 2022-05-29T15:49:40.652399Z

Reacted. You're close :)

mauricio.szabo 2022-05-29T19:28:13.815089Z

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

borkdude 2022-05-29T19:39:49.045519Z

Yep, I think @mauricio.szabo nailed it

pez 2022-05-29T19:51:00.384689Z

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

borkdude 2022-05-29T20:03:41.251899Z

Super!

borkdude 2022-05-29T20:08:53.086909Z

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

(apply gobject/getValueByKeys exports path)

borkdude 2022-05-29T20:09:20.735899Z

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

(.split module-name ".")

pez 2022-05-29T20:10:23.678119Z

Isn't that what I am doing?

borkdude 2022-05-29T20:10:44.971879Z

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

pez 2022-05-29T20:12:17.738569Z

So getValuesByKeys takes an array?

borkdude 2022-05-29T20:12:39.135569Z

yeah

pez 2022-05-29T20:13:01.180529Z

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

borkdude 2022-05-29T20:14:06.866229Z

apply also works, but my performance OCD was being triggered

borkdude 2022-05-29T20:14:31.790699Z

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

borkdude 2022-05-29T20:14:56.372209Z

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

borkdude 2022-05-29T20:15:11.834799Z

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

pez 2022-05-29T20:15:27.974639Z

Your OCD should have triggered when you wrote this: https://github.com/BetterThanTomorrow/joyride/blob/0db51d7298ef68536dd7157424a3ec19c02053a9/src/joyride/repl_utils.cljs#L48 😃

borkdude 2022-05-29T20:17:36.190339Z

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

pez 2022-05-29T20:17:38.262889Z

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

borkdude 2022-05-29T20:17:55.672369Z

Oh interesting. Can you name an example of that?

pez 2022-05-29T20:18:07.598639Z

Let's see...

pez 2022-05-29T20:19:29.295249Z

Contrived:

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

borkdude 2022-05-29T20:19:55.002039Z

brb

pez 2022-05-29T20:20:45.720439Z

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

borkdude 2022-05-29T20:43:40.709409Z

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

borkdude 2022-05-29T20:44:33.892229Z

["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

borkdude 2022-05-29T20:45:15.405909Z

You should probably write that as:

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

pez 2022-05-29T20:55:48.712369Z

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

borkdude 2022-05-29T20:56:42.226119Z

Ah right