On Jul 29, 2:02 pm, Ken Wesson <kwess...@gmail.com> wrote: > (fn [& args] > (let [argmap__5673__auto (#'some-ns/parse-args args) > foo (or (:foo argmap__5673__auto) 42) > bar (or (:bar argmap__5673__auto) nil) > ...] > (body goes here))) > where you define a private parse-args function in your namespace to > turn an argument seq into a map of argument name keywords to values, > with some omissions, and 42 and nil are the defaults which the macro > builds right into the function. > > Of course, this has the slight issue that arguments whose values are > false or nil will be changed to their defaults. You may need some > trickier handling, e.g. > > (let [... > foo (:foo argmap__5673__auto) > foo (if (:foo argmap__5673__auto) foo 42) > ...] > ...)
(get :foo argmap__5673__auto 42) is the right way to solve this problem. Or if, as in the current example, you want to destructure a map with lots of defaults, simply: (let [{:keys [foo bar] :or {foo 42}} (parse-whatever)] ...body...) > > or > > (let [... > foo (find argmap__5673__auto :foo) > foo (if foo (val foo) 42) > ...] > ...) > > -- > Protege: What is this seething mass of parentheses?! > Master: Your father's Lisp REPL. This is the language of a true > hacker. Not as clumsy or random as C++; a language for a more > civilized age. -- 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