I don’t like Clojure destructuring putting map keys after the vars to bind them to. There must’ve been some really compelling reason to do it this way, but oh god, it’s extremely broken and unjustifiable to me.
JS got it right.
I don’t like Clojure destructuring putting map keys after the vars to bind them to. There must’ve been some really compelling reason to do it this way, but oh god, it’s extremely broken and unjustifiable to me.
JS got it right.
@muhanga @aartaka Presumably referring to this:
(let [{resp-body :body} {:status 200 :body "Hello World"}]
resp-body) ; => "Hello World"
I imagine it feels odd because the (binding) key / val are reversed from the data being bound. (`[{a :a} {:a 1}]`).
Not entirely obvious to me that that *couldn't* have been done in the other order. OTOH, it does feel natural to keep the bound names to the left in a binding form.
@muhanga @aartaka I'd guess another factor in the design decision is the special keys like :as, :keys, :or, etc. which are somewhat analogous to keyword arguments, and thus would naturally live to the left of their values.
If keys to be destructured also went on the left then you could get collisions with those names.