2014-11-08 3:32 GMT+01:00 Blake McBride <blake1...@gmail.com>:

> Greetings,
>

Hi,

I am an old lisp guy that is new to Clojure.
>

Welcome!

Lisp can't do that without a real lot of work (make generic functions
> evaluate the arguments and then execute the applicable method).
>

This is exactly what Clojure does, via JVM Reflection.
When evaluating an interop form to call a java method like (.method object
arg1 arg2), the first step is to find the method on object's class. Then,
if multiple matching methods (based on arity) exist, a choice algorithm is
employed, mimicking java's static dispatch. You can read about this in full
detail in
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java

There's a builtin fast-path here: If the class of object can be inferred at
compile time, and if there is no ambiguity in the signature, it compiles
directly to an appropriate cast + method invokation.


> So, Closure would be able to call Java methods as if they were Closure
> functions taking into account the argument signature.  Does Closure do that?
>

Nope, regular Clojure function calls always go via clojure.lang.IFn

Also, I presume that a Closure program has immediate access to all Java
> classes and methods without any work.  Is that true?
>

Yes, that's what interop forms are for. They can look pretty much like
regular calls, but if you want to pass them as argument to a HOF, you need
to wrap them in a function.
Documentation on this should be easy to find.

kind regards

-- 
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