Re: "strange" pattern to implement comp, juxt and partial

2012-10-02 Thread Balint Erdi
Sorry, I was not precise enough. I meant why is this pattern not used in all of *clojure.core*. Every function that takes a variable number of arguments could use it but I only saw it in the mentioned cases. On Tuesday, October 2, 2012 10:29:15 PM UTC+2, Tamreen Khan (Scriptor) wrote: > > My g

Re: "strange" pattern to implement comp, juxt and partial

2012-10-02 Thread Tamreen Khan
My guess is that it's useful in the core functions which are more heavily used. Otherwise you're getting into premature optimization if you use it in any of your own functions without profiling it first. On Tue, Oct 2, 2012 at 4:18 PM, Balint Erdi wrote: > Makes sense but why don't we have it in

Re: "strange" pattern to implement comp, juxt and partial

2012-10-02 Thread Balint Erdi
Makes sense but why don't we have it in all possible places then? Thank you. On Tuesday, October 2, 2012 9:55:42 PM UTC+2, Herwig Hochleitner wrote: > > That is because dispatch on argument count is fast, while apply is slow. > Especially so since it might have to create an intermediate seq. > I

Re: "strange" pattern to implement comp, juxt and partial

2012-10-02 Thread Herwig Hochleitner
That is because dispatch on argument count is fast, while apply is slow. Especially so since it might have to create an intermediate seq. It's a performance optimization. kind regards -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gr

"strange" pattern to implement comp, juxt and partial

2012-10-02 Thread Balint Erdi
Hey, When browsing through clojure.core I noticed something peculiar in the implementation of comp, juxt and partial. All three share the same implementation pattern. They define separate methods for the arity of 0,1,2,3 and any. For example in juxt: (defn juxt (…) ([f g] (fn