On Jan 14, 2:14 pm, Ken Wesson <kwess...@gmail.com> wrote: > On Fri, Jan 14, 2011 at 12:43 PM, David Nolen <dnolen.li...@gmail.com> wrote: > > On Fri, Jan 14, 2011 at 12:07 PM, Sam Aaron <samaa...@gmail.com> wrote: > > >> I was wondering what purpose the '4 or fewer args' restriction serves and > >> therefore how you might retain the performance of this implementation with > >> 1.3.0-alpha4 and beyond (assuming the restriction is here to stay). Would > >> you have to break out into a number of smaller fns calculating the new x, y > >> length and angle vals? > > > Interfaces have to defined for every combination of primitive arguments - so > > you get interface explosion, thus only 4. > > The interfaces are needed only if the function is passed around as an > object or dynamically rebound; if it's just called at a few fixed > sites, those calls can be directly to a known class. > > Even then, couldn't the compiler generate the needed interfaces for a > specific Clojure project on the fly along with the appropriate calls? > > Are they even needed at all? Can a passed-around function be invoked > with unboxed primitive arguments? > > Later in the thread the OP is advised to wrap the primitive args in a > deftype and pass an instance of that. Manual boxing, in essence. Won't > that negate any performance improvement from using primitive args?
I don't think that's the case. The deftype can be type-hinted to have all of its fields be primitives, and then it only costs one object allocation and deref instead of the five you'd have to do to box each argument separately. -- 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