Re: Understanding when compilation occurs - for function producing functions

2014-06-22 Thread Mark P
​Well, you misunderstand it, as far as I know, clojure treat all fn as object, so in your adder-maker example, clojure compiled two fn as object, that's adder-maker itself and anonymous function it returns. You must be right. As far as I know, the compiler is only called as part of

Re: Understanding when compilation occurs - for function producing functions

2014-06-22 Thread Mark P
What's the reason for asking? If you aim for making efficient code (that is running very many times in tight loops), I think most of this will be inlined by the JIT, as long as it is not confused by side effects and other things. I'm asking mostly because I want to better understand

Re: Understanding when compilation occurs - for function producing functions

2014-06-22 Thread Mark P
A toy project I've worked intermittently on makes heavy use of *partial* to dynamically build complex functions. I wish that *partial* was smart enough to recompile its first argument, maybe taking advantage of whatever type inference the compiler can make, but partial

Re: Understanding when compilation occurs - for function producing functions

2014-06-22 Thread Reid McKenzie
Coming from a C++ background I'm not that familiar with functions as first class values. We sort of do have them in C++ - as functors - ie a class that has the function invocation operator defined. This class can have storage as well, which means you can have a functor object type which

Re: Understanding when compilation occurs - for function producing functions

2014-06-22 Thread Herwig Hochleitner
2014-06-22 9:12 GMT+02:00 Reid McKenzie rmckenzi...@gmail.com: since there's no other way that we can take a function as a value prior to JVM 1.8 which has bytecode lambdas and which the reference Clojure implementation doesn't leverage yet if ever. Java 8 gained no such feature. Lambda

Re: Understanding when compilation occurs - for function producing functions

2014-06-22 Thread Mark P
Okay. Functions as values. Go look at the IFn interface, https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IFn.java. Thanks for the link - this helps! When the clojure compiler generates a class type that conforms to this interface, does it generate a .java file

Re: Understanding when compilation occurs - for function producing functions

2014-06-22 Thread Ryan Schmitt
Okay. Functions as values. Go look at the IFn interface, https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IFn.java. Thanks for the link - this helps! When the clojure compiler generates a class type that conforms to this interface, does it generate a .java file

Re: Understanding when compilation occurs - for function producing functions

2014-06-22 Thread Alex Miller
On Sunday, June 22, 2014 11:35:25 AM UTC-5, Herwig Hochleitner wrote: 2014-06-22 9:12 GMT+02:00 Reid McKenzie rmcke...@gmail.com javascript: : since there's no other way that we can take a function as a value prior to JVM 1.8 which has bytecode lambdas and which the reference Clojure

Re: Understanding when compilation occurs - for function producing functions

2014-06-21 Thread Di Xu
Suppose at my REPL I do... (defn direct-report-oneplustwo [] (println (str Direct one plus two is ((fn [n] (+ 1 n)) 2) .))) ...then I presume that the compiler has compiled my direct-report-oneplustwo function, and that this has included compilation of my anonymous function (fn [n] (+ 1

Re: Understanding when compilation occurs - for function producing functions

2014-06-21 Thread Linus Ericsson
On Saturday, June 21, 2014, Di Xu xudi...@gmail.com wrote: Suppose at my REPL I do... (defn direct-report-oneplustwo [] (println (str Direct one plus two is ((fn [n] (+ 1 n)) 2) .))) ...then I presume that the compiler has compiled my direct-report-oneplustwo function, and that this has

Re: Understanding when compilation occurs - for function producing functions

2014-06-21 Thread David Andrews
A toy project I've worked intermittently on makes heavy use of *partial* to dynamically build complex functions. I wish that *partial* was smart enough to recompile its first argument, maybe taking advantage of whatever type inference the compiler can make, but partial

Understanding when compilation occurs - for function producing functions

2014-06-19 Thread Mark P
Suppose at my REPL I do... (defn direct-report-oneplustwo [] (println (str Direct one plus two is ((fn [n] (+ 1 n)) 2) .))) ...then I presume that the compiler has compiled my direct-report-oneplustwo function, and that this has included compilation of my anonymous function (fn [n] (+ 1 n)).