>
> 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 
which is then compiled using the java compiler?  I am guessing not.  I am 
guessing that clojure knows how to generate a byte code version of a class 
type directly.
 

> In C or C++ you can take a raw machine pointer to a function. The JVM 
> does not allow for this behavior the result of which is that whenever 
> you have a "function" really what you have is a function-like object 
> with the standard application/invocation member methods.


Thanks for explaining.  This sounds very much like a C++ functor.

For the record, the raw-pointer-to-function is the old-school thing to do 
in C++.  These days functors are often used - object types that have the 
function application operator defined (which is a method with special 
function application syntax) - because these are more powerful (eg 
templated methods allowing compile-time polymorphism) and allow for better 
performance (eg inlining of code).  So it sounds like what clojure does 
under-the-hood is to more-or-less define a functor type at compile time and 
then do various instantiations at run time.
 

> The "standard" Clojure compiler is pretty braindead when it comes to the 
> emitted bytecode, but this is due to the philosophy (backed up by 
> experience) that the JIT is typically good enough.


Good to know - thanks!  This makes things clearer for me.
 

> You could generate 
> better code, and my GSoC project is research into doing so but the 
> reality of Clojure programs is that function calls even with Var 
> indirection are free in comparison to the performance hits we take due 
> to using immutable datastructures and eschewing in place updates. 
>
> Reid  
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to