On Jan 16, 2009, at 2:46 PM, Greg Harman wrote:
> > As I chew on this, a couple of things don't sit right with me > regarding use cases: > > 1. IMHO gen-class should fail with an appropriate message/exception > rather than trying to "fix" the signature. This is what the Java > compiler would do if I made the same mistake in Java. More to the > point, an external Java class that tries to call my-method is going to > break since that method doesn't exist by that name. That breakage is > traceable no doubt, but it would be more effective to nip it in the > bud at compilation time. Agreed, this should be done before the 1.0 release. > > > 2. If I want the Clojure functions that underlie the methods in the > generated class used directly by my Clojure code as well (which I do), > then I'm stuck having to either violate standard Clojure/Lisp function > naming conventions in favor of Java-friendly naming or I have to write > wrapper functions like: > > (defn myMethod [obj] (my-method obj)) > > Other than using the prefix and keeping the method names to one > "word", is there a better way? Since gen-class is used to create Java classes, it's sensible that the naming convention within the generated class be Java's. > > > -Greg > > On Jan 16, 1:02 pm, Kevin Downey <redc...@gmail.com> wrote: >> - is not a "Java letter or digit" so it is not allowed in java >> method names. >> >> http://java.sun.com/docs/books/jls/third_edition/html/ >> lexical.html#3.8 >> >> user=> (Character/isJavaIdentifierPart (int \-)) >> false >> user=> >> >> >> >> On Fri, Jan 16, 2009 at 9:56 AM, Greg Harman <ghar...@gmail.com> >> wrote: >> >>> I think I may have found a minor issue with gen-class, but wanted to >>> confirm with the group that I'm not just doing something stupid... >> >>> (gen-class :name mypkg.foo >>> :prefix "" >>> :methods [[my-method [Object] Object]]) >> >>> Results in the following method signature in the .class file: >> >>> public Object my_2D_method(Object obj) { >> >>> "-" is being written out as "_2D_" >> >>> -Greg >> >> -- >> And what is good, Phaedrus, >> And what is not good— >> Need we ask anyone to tell us these things? > > --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---