Re: Functions destructuring maps in the arglist

2011-06-17 Thread Ken Wesson
On Thu, Jun 16, 2011 at 9:51 AM, Tassilo Horn tass...@member.fsf.org wrote: 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}]

Re: Functions destructuring maps in the arglist

2011-06-17 Thread Tassilo Horn
Ken Wesson kwess...@gmail.com writes: Hi Ken! That somehow makes sense, but is there some way to get the complete map with defaults applied, too? (defn foo  [{:keys [a b]    :or {a 1 b 2}    :as all}]   (let [all (merge {:a 1 :b 2} all)] [(hash-map :a a :b b) all])) Of course

Re: Functions destructuring maps in the arglist

2011-06-17 Thread Ken Wesson
On Fri, Jun 17, 2011 at 2:31 PM, Tassilo Horn tass...@member.fsf.org wrote: Ken Wesson kwess...@gmail.com writes: Hi Ken! (defmacro defnm [name argvec body]   `(defn ~name ~argvec      (let ~(vec              (apply concat                (for [a argvec :when (and (map? a) (:or a) (:as

Functions destructuring maps in the arglist

2011-06-16 Thread Tassilo Horn
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