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
TIL
(#(+ % (#(- % 2) 3)) 3) => 4
Haha.
I noticed joker also allows this btw
But I think bb / edamame will disallow it also at one point
just for compatibility
I thought clojure didn't allow nesting anon functions š±
babashka does ;)
There is an issue for this: https://github.com/borkdude/edamame/issues/76
clj-kondo should probably warn about this too
I dragged that clj-kondo issue all the way to the top now
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. š
Maybe discourage those fn literals a bit, since they are ugly anyway
This is obviously subjective ;)
But I think I could live without them
It needs to be short, donāt have room for judging, š
make sense ;)
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.
Iām moving more towards ānamedā lamdas myself, actually.
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
Is Clojureās non-nesting rule a sort of opinion, you think?
I think it's mostly to avoid confusion, I don't see another reason
#(foo % #(foo %))
this expands into
(fn [%1] (foo %1 (fn [%1] (foo %1))))
in sci basicallywhich is just valid clojure
user=> '#(foo % #(foo %))
(fn* [%1] (foo %1 (fn* [%1] (foo %1))))
I guess nesting fn literals also leads to the problem of shadowed locals
which you can have with normal fns as well, but maybe not as much