On Nov 21, 4:20 pm, Craig McDaniel <[EMAIL PROTECTED]> wrote:
> Testing the new (ns ... :genclass ...), I copied Rich's example 
> fromhttp://paste.lisp.org/display/70665:
>
> (ns my.hello
>   (:gen-class
>    :extends javax.swing.DefaultCellEditor
>    :constructors {[Integer] [javax.swing.JCheckBox]}
>    :factory makeone
>    :methods [[mymax [int] int]]
>    :init init
>    :main true
>    :state myint
>    :exposes {clickCountToStart {:get get-c-count :set set-c-count}})
>   )
>
> (defn- -main [foo]
>   (println "Hello" foo "World!")
>   (let [x (my.hello. 42)]
>     (prn (.mymax x 21))))
>
> (defn- -init [myint]
>   [[(javax.swing.JCheckBox.)] myint])
>
> (defn- -mymax [this i]
>   (max i (.myint this)))
>
> (defn- -getCellEditorValue [this]
>   (prn :getCellEditorValue)
>   nil)
>
> I can compile and run the example, but it doesn't work with the "/"
> syntax for main, even though main is a static method:
>
> user> (.getProperty System "java.class.path")
> "/home/kreg/src/clojure/trunk/clojure.jar:/home/kreg/src/junk"
> user> (binding [*compile-path* "/home/kreg/src/junk"] (compile
> 'my.hello))
> #{my.hello swank ...}
> user> (.main my.hello (into-array ["Bizarro"]))
> Hello Bizarro World!
> 42
> nil
> user> (my.hello/main (into-array ["Bizarro"]))
>
> java.lang.Exception: No such var: my.hello/main
>
> Works from command line ok:
>
> [EMAIL PROTECTED] ~/src/junk
> $ java -cp .:/home/kreg/src/clojure/trunk/clojure.jar my.hello
> "Bizarro"
> Hello Bizarro World!
> 42

Right. The x/y syntax is used both for namespaces and static methods,
and namespaces win. Here you have both a namespace and a classname
called my.hello. So, for calling gen-class'ed static methods, you'll
need to use (. classname static-method) for now.

I'm not sure this is really an issue, but I'm open to feedback.

Rich

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to