We know that while associative destructuring, :as gives us a symbol for the incoming map, and :or the means to define default values if the keys are not there.
But how to get a reference to the whole new map?
Let me explain, let’s imagine you can do it with something called :merged-as. Then, I would be expecting the following:
(let [{:keys [a b c] :or {a 1 b 2 c 3} :as m :merged-as merged} {:b 20}]
[m merged]) ;; [{:b 20} {:a 1 :b 20 :c 3}]
When I first got started with map destructuring, I found it very odd that the :as hash map was before the default values were added and I’ve often wished for some shorthand to do this, but I guess I just got used to the let-with-merge approach and never got around to asking for enhancement…
I never even realized that :as didn’t include the other stuff.
I think the thought process must have been that :as refers to the original input, and they’d expect you to use the bound symbols inside the function for the rest.
It could make for a good clj-kondo linter, that warns if you’re getting an :or key from the :as map.