Re: Calling an overloaded Scala function

2015-06-26 Thread Stephen Wakely
I want to fully understand what is going on before doing anything. Interestingly if I convert the Java code below to Scala it fails to compile with the same error : def Onk(str: util.ArrayList[String]): String = { println("String") "erk" } def Onk(it: util.ArrayList[Integer]): Integer = {

Re: Calling an overloaded Scala function

2015-06-26 Thread Ambrose Bonnaire-Sergeant
Have you considered writing a wrapper method in Scala and calling that? Thanks, Ambrose On Fri, Jun 26, 2015 at 7:24 PM, Stephen Wakely wrote: > Sorry about the double threads - I messed up and thought the original post > didn't go through. > > Looking further into this it seems in Java generic

Re: Calling an overloaded Scala function

2015-06-26 Thread Stephen Wakely
Sorry about the double threads - I messed up and thought the original post didn't go through. Looking further into this it seems in Java generics are largely a compile time thing. The generic type information is wiped out from the type on compile. So how does Java know which overload to call when

Re: Calling an overloaded Scala function

2015-06-25 Thread Ambrose Bonnaire-Sergeant
That was meant as a response to the other thread. On Fri, Jun 26, 2015 at 10:35 AM, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > They apparently differ in the return type. I don't think > clojure.lang.Reflector considers the return type hint > when resolving methods. > > Than

Re: Calling an overloaded Scala function

2015-06-25 Thread Ambrose Bonnaire-Sergeant
They apparently differ in the return type. I don't think clojure.lang.Reflector considers the return type hint when resolving methods. Thanks, Ambrose On Fri, Jun 26, 2015 at 4:16 AM, Stephen Wakely wrote: > javap gives : > > public com.cra.figaro.language.AtomicDist > apply(scala.collection.

Re: Calling an overloaded Scala function

2015-06-25 Thread Stephen Wakely
javap gives : public com.cra.figaro.language.AtomicDist apply(scala.collection.Seq>>, com.cra.figaro.language.Name, com.cra.figaro.language.ElementCollection); public com.cra.figaro.language.CompoundDist apply(scala.collection.Seq, com.cra.figaro.language.Element>>, com.cra.figaro.language.N

Re: Calling an overloaded Scala function

2015-06-25 Thread Stephen Wakely
So using reflection on the objects gives the following signatures - they have identical signatures : {:name apply, :return-type com.cra.figaro.language.CompoundDist, :declaring-class com.cra.figaro.language.Dist$, :parameter-types [scala.collection.Seq com.cra.figaro.language.

Re: Calling an overloaded Scala function

2015-06-25 Thread Stephen Wakely
I am sadly quite clueless when it comes to Java. De-compiling the Scala class file to Java gives me the following: public AtomicDist apply(Seq>> clauses, Name name, ElementCollection collection) { return new AtomicDist(name, clauses.toList(), collection); } public Compou

Re: Calling an overloaded Scala function

2015-06-25 Thread Stuart Sierra
Scala has to compile down to JVM bytecode just like Clojure, but it may change method signatures along the way. You could try running `javap` to disassemble the compiled Scala bytecode and figure out what the method signatures actually are. Or use Java reflection to examine the objects you have

Re: Calling an overloaded Scala function

2015-06-25 Thread Ambrose Bonnaire-Sergeant
Do you know how to call this method from Java 1.4? That will probably give enough context to use in Clojure type hints. Thanks, Ambrose On Thu, Jun 25, 2015 at 9:03 PM, Stephen Wakely wrote: > Interesting. That could be a good last resort. > > On Thu, Jun 25, 2015 at 1:27 PM Andy Fingerhut > w

Re: Calling an overloaded Scala function

2015-06-25 Thread Stephen Wakely
Interesting. That could be a good last resort. On Thu, Jun 25, 2015 at 1:27 PM Andy Fingerhut wrote: > Sorry, I do not know whether Clojure can or cannot determine the correct > overload in this situation. > > All I have is a weak suggestion that work well enough: have you considered > creating

Re: Calling an overloaded Scala function

2015-06-25 Thread Andy Fingerhut
Sorry, I do not know whether Clojure can or cannot determine the correct overload in this situation. All I have is a weak suggestion that work well enough: have you considered creating wrapper functions, e.g. in Scala or Java, that have different enough function signatures that Clojure can easily