Fork me on GitHub
#clojure-europe
<
2021-11-14
>
val_waeselynck08:11:30

So glad to be actually able to greet you in the morning now. It's good to be back.

❤️ 1
slipset11:11:10

Oh, the perils of multi-arity fns.

slipset11:11:30

You call the fn with the wrong arity, and clj-kondo is not there to help you, because it’s nothing it can do.

borkdude11:11:55

you probably mean varargs

borkdude11:11:32

clj-kondo can see multi-arity errors

slipset11:11:55

Ah, but no, and I’m not blaming clj-kondo here, only myself:

(defn foo
  ([one] ...)
  ([one two] ...))
Now when I call (foo 1) rather than (foo 1 2) as I should have done, clj-kondo can’t help me. A bit lik when you call (map bla) and you get a transducer rather than your mapped seq

borkdude11:11:20

ah yes, but with the transducer stuff clj-kondo does actually help in some cases :) e.g. (first (map inc)) gives a warning

genRaiy13:11:38

wrt to mult-arity fns - the usual answer is passing a map - the map can be spec'ed and / or checked with :pre ... still can FU though :man-shrugging::skin-tone-3:

slipset13:11:47

One thing I haven't pondered much is that we tend to not recommend fns which change their return type depending on the params. But all the transducer fns in core do exactly that.

😬 1
1
Jakub Holý (HolyJak)11:11:23

Rules are meant to be broken, when a strong argument for just that arises 🙂

borkdude14:11:06

Yeah, unfortunately.

borkdude14:11:00

Perhaps the thinking was that you could easily migrate from thread last to comp.