Thanks guys, I think I will go with this variant that vemv suggested and upon further exploring I realized it can do much more (still exploring currently):
*(defn somefn [req1 req2 **;required params * *& {:keys [a b c d e]** ;optional params* *:or {a 1** ;optional params with preset default values other than the nil default* * ; b takes nil if not specified on call* * c 3** ; c is 3 when not specified on call* *d 0* *; d is 0 --//--* * ; e takes nil if not specified on call* * } :as mapOfParamsSpecifiedOnCall }] (println req1 req2 mapOfParamsSpecifiedOnCall a b c d e) )* *=>* *(somefn 9 10 :b 2 :d 4)* 9 10 {:b 2, :d 4} 1 2 3 4 nil nil *=>* *(somefn)* ArityException Wrong number of args (0) passed to: funxions$somefn clojure.lang.AFn.throwArity (AFn.java:437) *=>* *(somefn 9 10)* 9 10 nil 1 nil 3 0 nil nil =>* (somefn 9 10 :x 123)* 9 10 {:x 123} 1 nil 3 0 nil nil => *(somefn 9 10 123)* IllegalArgumentException No value supplied for key: 123 clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77) =>* (somefn 9 10 123 45)* 9 10 {123 45} 1 nil 3 0 nil nil On Sun, Feb 17, 2013 at 10:12 PM, vemv <v...@vemv.net> wrote: > fn's "keyword arguments" feature provide unrolled, optional key-value args: > > (defn foo [& {:keys [a b c]}] > [a b c]) > > (foo :c 4) ;; [nil nil 4] > > > On Sunday, February 17, 2013 10:06:13 PM UTC+1, AtKaaZ wrote: >> >> Was there a library or some other way to pass ie. maps to functions >> so that the order of the params isn't predefined, just in case I want to >> skip some passing parameters without actually having to pass some value for >> them, I could just refer to which params I'm passing by identifying them >> with a :key ? >> >> It's probably not hard at all to implement, but if there's a lib already, >> it would do a better job that I could. >> >> -- >> Please correct me if I'm wrong or incomplete, >> even if you think I'll subconsciously hate it. >> >> -- > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.