Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
OK, I understand. When you want separate Clojure functions that execute different code for same arity/different signature case, you must use the method demonstrated by Christophe. The code I showed was only useful when you don't care about the type. You could use the multi-arity function and manua

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
Hello, The code you provided works well. But still, I insist, it has nothing to do with how to solve the problem of how one can overload methods with same name, same arity, but different types in the signature. You only demonstrated that clojure handles well the dispatching of method calls based

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
I guess I don't understand. In the Clojure code below, the double arity method does in fact override all three of the methods from the superclass (two of which have the same name and same arity). Isn't that what you're looking for? Try it out. |-- build.xml |-- go.clj |-- src | `-- expmeth |

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
Yes, but please note that Christophe's method also solves the problem of defining overloaded methods with different java signatures, but still same name and same arity. I still can't see how your proposed method solves this particular problem ? Regards, -- Laurent 2009/2/13 Craig McDaniel >

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
Both my method (multi-arity) and Christophe's method (overridden method names contain arguments) do work. I tested them both with the code posted. -Craig --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" grou

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
Didn't know, thank you again for this knowledge, -- laurent 2009/2/13 Craig McDaniel > > On Feb 13, 9:59 am, Laurent PETIT wrote: > > Your example code below is not complete (where's helloSuper definition > ?), > > Yes, it is complete. See :exposes-methods under (doc gen-class). > "helloSuper

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
On Feb 13, 9:59 am, Laurent PETIT wrote: > Your example code below is not complete (where's helloSuper definition ?), Yes, it is complete. See :exposes-methods under (doc gen-class). "helloSuper" is the exposed name for the hello method in the superclass. Clojure creates that method for you. -C

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
Hello , Your example code below is not complete (where's helloSuper definition ?), but I think it does not answer my specific question ? Anyway, it seems that Christophe found the answer. But I don't know if we should use this knowledge, since it is not exposed as an API ? -- Laurent 2009/2/1

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
Thanks Christophe, that's the answer I was hoping to get, If I was twenty years younger, I would just say Clojure roxxXXooRR :-) (well, I think this is supposed to say that clojure is really cool, hope I didn't misunderstood the rooxxXXooRR "thing" :-) -- Laurent 2009/2/13 Christophe Grand >

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
Christophe, you're right. I tried it and that method also works. I didn't know about that secret feature. (ns expmeth.TestMe (:gen-class :extends expmeth.ClassA :exposes-methods {hello helloSuper})) (defn -hello [this] (.helloSuper this) (println "hello from clojure!")) (defn

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
??? 2009/2/13 Craig McDaniel > > I just tried it out to be sure. Overloaded methods with the same arity > work as expected. Clojure picks the right method to call via > reflection. > > package expmeth; > public class ClassA { >public void hello() { >System.err.println("hello from Jav

Re: generated class with overloaded methods

2009-02-13 Thread Christophe Grand
Laurent PETIT a écrit : > 2009/2/13 Christophe Grand > > > > Laurent PETIT a écrit : > > Hello, > > > > Thanks for having shared that, > > > > Do you know if there's a way to overload methods with the same > arity, > > then ? > > >

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
I just tried it out to be sure. Overloaded methods with the same arity work as expected. Clojure picks the right method to call via reflection. package expmeth; public class ClassA { public void hello() { System.err.println("hello from Java!"); } public void hello(int x) {

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
2009/2/13 Christophe Grand > > Laurent PETIT a écrit : > > Hello, > > > > Thanks for having shared that, > > > > Do you know if there's a way to overload methods with the same arity, > > then ? > > > > I'm thinking about .read(char ) .read(byte ) .read(String ) > > .read(Integer ) ... for example

Re: generated class with overloaded methods

2009-02-13 Thread Christophe Grand
Laurent PETIT a écrit : > Hello, > > Thanks for having shared that, > > Do you know if there's a way to overload methods with the same arity, > then ? > > I'm thinking about .read(char ) .read(byte ) .read(String ) > .read(Integer ) ... for example, ? Create functions named -read-char -read-byt

Re: generated class with overloaded methods

2009-02-12 Thread Stuart Sierra
On Feb 12, 6:12 pm, Laurent PETIT wrote: > Do you know if there's a way to overload methods with the same arity, then ? > > I'm thinking about .read(char ) .read(byte ) .read(String ) .read(Integer ) > ... for example,  ? I think they're all the same method, from the Clojure point of view. If yo

Re: generated class with overloaded methods

2009-02-12 Thread Laurent PETIT
Hello, Thanks for having shared that, Do you know if there's a way to overload methods with the same arity, then ? I'm thinking about .read(char ) .read(byte ) .read(String ) .read(Integer ) ... for example, ? -- Laurent 2009/2/12 Craig McDaniel > > For the benefit of others, since this t

generated class with overloaded methods

2009-02-12 Thread Craig McDaniel
For the benefit of others, since this took me a while to understand... When using gen-class to extend or implement a superclass with overloaded methods, use a single multi-arity function to override the overloaded methods in the superclass: expmeth/ClassA.java: package expmeth; public class Clas