Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Syntax and reader by

I happened to define a function like this

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

Obviously the destructuring is wrong, it should have been

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

My question is then, should this destructuring error be caught by the specs for destructuring?

1 Answer

0 votes
by
selected by
 
Best answer

You can use keywords in destructuring (most useful when using namespaced keywords). Treating :as as special would be surprising and breaking existing code.

by
The thing you can have in the `:keys` vector is governed by `core/ident?` which says `symbol?` or `keyword?`.

TIL
...