Re: Need advice/idiom to reduce number of parameters in functions

2015-05-13 Thread Herwig Hochleitner
In functional programming you can do a similar thing as in OOP: Define your functions as closures that can access common arguments via lexical scope. So instead of creating a context object, you create functions: (defn make-context [some context parameters] {:op1 (fn [x] ...) :op2 (fn [y]

Re: Need advice/idiom to reduce number of parameters in functions

2015-05-13 Thread David James
Well, this is question many people ask. :) It is a matter of tradeoffs: - Too many arguments may be an aesthetic problem. It may also reflect a design problem; you might be able to rethink a system to simplify it. (What too many means is debatable.) - With many arguments, you may

Need advice/idiom to reduce number of parameters in functions

2015-05-12 Thread Chris Wong
I have a set of functions that need a map of historic data. Hence, this map gets passed along from function to function, usually several levels deep. In addition to the map, a reference date also frequently get passed along in 80% of the API. Sometimes a third or fouth parameter is also