Hi all, I have some functions that use destructuring on a map parameter, and it seems I have a false assumption on the workings. Take for example this one:
(defn foo [{:keys [a b] :or {a 1 b 2} :as all}] [(hash-map :a a :b b) all]) I expected it to always return a vector of two equal maps. However, that's not true. all is in fact the map I gave at the call, not the map with the default values declared in the :or applied. Why is that? So that you can distinguish given actual args that happen to match default values from real, non-given defaults? That somehow makes sense, but is there some way to get the complete map with defaults applied, too? In my application, I don't care about if some value is an implicit or explicit default, but I have some functions with many keys that are split in two subfunctions. One public frontend functions with :or in order to let callers see the defaults, and one private function that does the actual work, assumes correct args and is called by the public one: (defn- foo-1 [{:keys [a b c]}] ...) (def foo [{:keys [a b c] :or {a 1 b 2 c 3} :as all}] ;; do some stuff ;; (foo-1 all) ;; That won't work, instead I have to do the lengthy... (foo-1 (hash-map :a a :b b :c c)) ;; do more stuff ) Any recourse? Bye, Tassilo -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en