Ah, thanks Meikel for the explanation. Ok, so a function like + avoids this boxing, because it's really replaced by a call to clojure.lang.Numbers.add()... And looking at the sourcecode, this is accomplished through :inline. This :inline declaration allows + to avoid IFn's rules, because + disappears after compiletime.
If correct, that makes sense. Thanks for the enlightenment, Tayssir On Aug 12, 12:01 pm, Meikel Brandmeyer <m...@kotka.de> wrote: > Hi, > > On Aug 12, 11:54 am, Tayssir John Gabbour > > <tayssir.j...@googlemail.com> wrote: > > On this topic, how do primitives work? I heard something about > > "function boundaries." Which I interpret to mean that when a function > > returns a primitive, Clojure boxes it in some Java object. And type > > declarations can't stop this boxing from happening. > > > Is this a correct understanding? > > This is correct, because the invoke methods of the IFn interface > are based on Object, thus cannot return (or take) primitives. > > > And what is the performance penalty here? > > Not sure, but putting performance critical code into > a let with unboxing the primitives proofed to be a > good idea in the past. > > Sincerely > Meikel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---