Fork me on GitHub
#babashka
<
2021-02-16
>
borkdude11:02:33

Made an (unedited, improvised) video on how we (at work) solve our deps.edn monorepo issues with a babashka script. https://youtu.be/PIwKYJh3r-Y

👍 12
pez21:02:19

TIL

(#(+ % (#(- % 2) 3)) 3) => 4

ericdallo21:02:26

I thought clojure didn't allow nesting anon functions đŸ˜±

borkdude21:02:00

babashka does ;)

babashka 15
borkdude21:02:05

clj-kondo should probably warn about this too

borkdude21:02:18

I dragged that clj-kondo issue all the way to the top now

clj-kondo 3
pez21:02:35

I’m writing a small Clojure primer and had just mentioned “function literals can’t be nested”, then evaluated my example for it. (Which to my surprise wasn’t marked by the linter.) Only, I was using a babashka REPL. 😃

borkdude21:02:06

Maybe discourage those fn literals a bit, since they are ugly anyway

borkdude21:02:31

This is obviously subjective ;)

borkdude21:02:37

But I think I could live without them

pez21:02:43

It needs to be short, don’t have room for judging, 😃

borkdude21:02:25

make sense ;)

pez21:02:25

They are quite unnecessary, though, I agree. I’m mainly mentioning them as part of mentioning the dispatch character, and also so that you will recognize them when reading Clojure code.

pez21:02:22

I’m moving more towards “named” lamdas myself, actually.

borkdude21:02:05

We could have an optional linter for disallowing fn literals, but I'm not sure if I would go so far as to use it myself

pez21:02:46

Is Clojure’s non-nesting rule a sort of opinion, you think?

borkdude21:02:32

I think it's mostly to avoid confusion, I don't see another reason

#(foo % #(foo %))

borkdude21:02:34

this expands into

(fn [%1] (foo %1 (fn [%1] (foo %1))))
in sci basically

borkdude21:02:42

which is just valid clojure

borkdude21:02:06

user=> '#(foo % #(foo %))
(fn* [%1] (foo %1 (fn* [%1] (foo %1))))

borkdude21:02:21

I guess nesting fn literals also leads to the problem of shadowed locals

borkdude21:02:33

which you can have with normal fns as well, but maybe not as much

borkdude20:02:08

I noticed joker also allows this btw

borkdude20:02:29

But I think bb / edamame will disallow it also at one point

borkdude20:02:32

just for compatibility