Description
https://groups.google.com/u/0/g/clojure/c/iyyNyWs53dc?pli=1
- Variable arg lists have to go last;
- The "operand," i.e. the object primarily being "operated upon,"
goes last, to make partial application easier and nested expressions
easier to read;- If a function/macro takes a collection, the collection goes last.
Skimming through the API, it seems like most of the built-in functions
fit these rules, with a few exceptions:
conj contains? find get nth nthrest select-keys subs subvec with-meta
set/project
Hmmm... Good thing those weren't the rules or assoc/dissoc couldn't
have become variadic. I know it might seem arbitrary, but it's
(usually :) not.
A better characterization (but not a rule, no promises) might be that
the sequence functions take the seq last, and the collection functions
take the collection first.
I think with #() the partial application story is always easy - no
matter what the argument order you often want to bind args other than
the first.
Rich
I think the tradition is more general: abstract process which need missing process passed in(seems all high order functions under this category) should have missing process comes first as it's parameter.
This tradition not only limited to sequence parameter.
Also can we consider that put some special argument in some special position.
The main problem data, which often be the criteria of function dispatch, similar to OO's method target object, can as first parameter or after the missing process parameter?
So we can have a consistent parameter order model:
missing-process-param*, main-problem-data-param, additional-param*
With this model maybe we get better use of "->" to focus on & thread main problem:
E.g.
(->
main-problem-data
concrete-func-1
(concrete-func-2 additional-param)
((partial abstract-func-1 missing-process-1 missing-process-2))
((partial abstract-func-2 missing-process) additional-param))