On Wednesday, April 30, 2014 10:22:55 PM UTC-5, Colin Fleming wrote: > > Hi everyone, > > After the very interesting keyword argument debate, I have another > question about API design. Specifically I'm interested in suggestions about > parameter order. The new API guidelines, which have changed very recently > to favour maps over keyword args, also changed to include a suggestion that > the keyword map be the first argument, since it's the "least variance" > argument. > > I've been using some fairly simple rules to order my parameters, basically > 1) functions that operate on collections should have the collection last to > interoperate with ->>, >
> > and 2) functions operating on a "main" object should accept that first, to > interoperate with ->. #2 is generally pretty intuitive since it's the same > as Java interop and protocol calls, but there's still a fair amount of > ambiguity with just these rules unless all your functions have one or two > arguments. > In the core library, collection functions (that take a collection and return a modified collection, ex: get, assoc, conj) take their argument *first* and work with ->. Sequence functions (which take a seqable and return a sequence) take their argument *last* and work with ->>. I would suggest that as a first preference. > > I'm interested in opinions about the "variance" ordering, since I assume > this is to facilitate use of partial and the like. I never really use > partial myself so I don't have a good feeling for how this ordering should > work - any comments or opinions? > I don't tend to use partial a lot but do occasionally re-order args to make that feasible. > > Thanks, > Colin > -- 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/d/optout.