Fork me on GitHub
#clojure-europe
<
2020-09-09
>
kardan03:09:28

Good morning

slipset05:09:11

God morgen!

synthomat05:09:17

good morning!

ouvasam06:09:14

Bonne journée à tous !

slipset07:09:13

lost half an hour of my life on this:

(defn foo [{:keys [bar :as lol]}] lol)

slipset07:09:36

I'm sure clj-kondo would have caught it in one way or another.

borkdude07:09:27

yup ;)

😂 3
slipset07:09:15

I posted a question on http://ask.clojure.org about this, since I do think this is nonsensical and could/should be caught by a destructuring-spec.

borkdude08:09:29

@slipset It's not nonsensical. you can use keywords in destructuring (most useful when using namespaced keywords) and treating :as as special would be surprising

slipset08:09:34

Right,

(let [{:keys [:as]} {:as 'foo}] as)

slipset08:09:16

I can see how this would be useful (and I have used it) with namespaced kws, but it's a bit more far fetched with non-namespaced kws.

borkdude08:09:35

That ship has also long sailed, it's been there for a long time and won't be changed.

slipset08:09:48

It's a linter 🙂

borkdude08:09:00

Some people even prefer it over symbols, as it's easier to grep for keywords

slipset08:09:09

Don't use non-namespaced keywords in :keys destructuring 🙂

borkdude08:09:09

We use it in our codebase at work almost everywhere

borkdude08:09:39

It can definitely be an optional linter

borkdude08:09:47

but it's very much a taste / preference thing

borkdude08:09:17

maybe mixed style in one destructuring can be seen as bad

borkdude08:09:23

but clj-kondo already catches this sillyness by reporting :as as an unused binding, so I think it's sufficiently covered

3
slipset08:09:09

Well, I learned a couple of things, amongst them, a function called ident? which was added in 1.9