Fork me on GitHub
#clojure-europe
<
2022-05-09
>
jkxyz06:05:41

Morning!

genRaiy08:05:13

Good morning

❤️ 2
genRaiy08:05:12

He's feeling Monday too

practicalli-johnny08:05:09

I hope they are not a shadow of their former self... :face_palm:

😂 2
🤡 2
otfrom10:05:05

I have a function that takes (f {:arg-1 val-1 :arg-2 val-2}) and I'd like it to also take (f val-1 val-2) should I have the one that takes the map call the one where order matters or should I take the one where order matters and put the values into a map? Or is there a new clojure 1.11 magic way of handling this that I don't understand yet?

otfrom10:05:59

calling (f :arg-1 val-1 :arg-2 val-2) feels about as painful as putting things in the map, but might be faster I suppose? idk 🤷

borkdude10:05:33

in clojure 1.11 both passing a map and the latter works if you use & {:keys ...}

borkdude10:05:22

but personally I don't think it's worth supporting (f :arg-1 val-1) vs. (f {:arg-1 val-1}) - always using a map gives less headaches imo

👌 1
borkdude10:05:00

Using fixed args is better for performance as no destructuring needs to happen, so I would have the map version call the fixed args one, if possible, and leave the fixed args one to do the least amount of work possible to process the args. If performance is a concern. If you are going to do an http request or database query in that function, none of this matters.

otfrom10:05:51

it isn't the most performance sensitive bit of the code, but I was more wondering about the general principle as some of the bits will be very performance sensitive, so I at least want to avoid the big hits even if I do take some hits for expressiveness

Ben Sless13:05:57

You can cheat and provide a user friendly API with a map and an inline meta that will examine the call site and unpack a literal map to positional

otfrom13:05:55

in this instance the user friendly API is the positional one

otfrom13:05:19

I'm not sure what that inline meta would look like. I know how to do the overloading though

borkdude10:05:11

in general, fixed args for perf sensitive functions / functions used in hot loops

otfrom10:05:34

I was thinking that, but wasn't sure if that was true under 1.11

borkdude10:05:02

everything with & {:keys ...} is not very performant

borkdude10:05:33

clojure 1.11 just added convenience

maleghast10:05:15

Madainn mhath

pez12:05:23

Morning!

val_waeselynck13:05:15

Would you rather (A) (->> ... (mapcat identity) ...) or (B) (->> ... (sequence cat) ...) ? Discuss

Jakub Holý (HolyJak)07:05:52

there is a deep discussion of this at https://chouser.us/apply-concat/ Personally I have a 🐈 🙂

🙏 2
otfrom13:05:22

is there a way to avoid the ->>?

val_waeselynck13:05:04

not really in this context

val_waeselynck13:05:22

(I'm leaning towards (B), because dogs are over-represented here)

catjam 1
otfrom13:05:36

I agree w/your reasoning on B

val_waeselynck13:05:47

Seriously, I think I'm going for (A), less abstract, more accessible to future readers

potetm13:05:05

imo mapcat identity is almost always a sign of something else gone funky

val_waeselynck14:05:21

This example confirms it: the ElasticSearch Bulk API can definitely be described as 'something gone funky'

laughcry 1
potetm14:05:17

Yeah the whole json-but-not-actually-json thing is fun

potetm14:05:29

it makes sense, but it’s fun

slipset14:05:18

Probs doesn’t solve the upstream problem, but it would sometimes be nice with a flatten1 which only did (mapcat identity...)

val_waeselynck17:05:13

> Yeah the whole json-but-not-actually-json thing is fun That, and having 2 values, one for identifying the document and one for writing to it And the whole schema of "you will find the operation type as the key in the only entry of the map"

potetm17:05:39

lol oh yeah I forgot about the opt type quasi-tuple thing

potetm17:05:43

what a clown car

slipset17:05:21

https://www.studentnewsdaily.com/wp-content/uploads/2015/05/clowns-820x555.png is my favorite clown car. Much because of the duck on top. Don’t ask why.

lol 1
💯 1
😄 1
😆 2
duckie 2
Michaël Salihi13:06:07

Little bit late to the party 🙂 https://youtu.be/sR_rPd_ufK4

potetm13:05:10

same for keep identity

slipset14:05:11

Why would you keep identity , and would (filter some?) be more reasonable?

potetm14:05:19

yeah (filter some? makes more sense, but it still points to some upstream issue imo

potetm14:05:20

Usually, you could have used either keep or mapcat at some point.

potetm14:05:50

Actually, were I forced into it, I would probably do (remove nil? …)

pez13:05:51

It's amazing to see #joyride used for providing the #portal UI as a data inspector to #calva. https://github.com/BetterThanTomorrow/calva/issues/1717 Despite both Portal and Calva lacking API for it. A true Joyride of those two tools! @orestis 👑

😍 2
orestis14:05:30

Having the REPL made this trivial :)

orestis14:05:38

I wonder if the Calva team will shift into writing more CLJS now that you can have a REPL

pez15:05:27

Probably not. We always run into troubles using the vscode API from ClojureScript. The mix of TS and CLJS seem not to allow it. While it is fine in Joyride which is pure CLJS.

pez15:05:54

I enjoy the REPL a lot when working with the ClojureScript parts of Calva though, so this with extension authoring using the REPL is not new to me. 😃

pez15:05:07

And maybe with some API on the Calva extension we can write some high level functionality with Joyride.

orestis17:05:05

Yes, a lot of things will be possible with a first class Calva API for certain things. Probably more around evaluation rather than eg editing or highlighting.