Adrian Cuthbertson a écrit :
> Hi Christophe,
>
> It works as per your example, but not with arguments to the method...
>
> ns gncls.MyStatic
>   (:gen-class
>      :methods [#^{:static true} [f [String] void ]]))
>
> (defn -f
>   [s] ; also [this s] doesn't work
>   (prn "Hi from " s ))
>
> (gncls.MyStatic/f "me")
> java.lang.Exception: No such var: gncls.MyStatic/f (NO_SOURCE_FILE:2

Hmm, the exception says it is looking for gncls.MyStatic/f, not for 
gncls.MyStatic/-f, it hints me that you are not going through the static 
method at all but directly to the function through the namespace 
gncls.MyStatix. Try and contrast:

(ns gncls.MyStatic
  (:gen-class
     :methods [#^{:static true} [f [String] void ]]))

(defn -f
  [s]
  (prn "Hi " s "from -f"))

(defn f
  [s]
  (prn "Hi " s "from f"))

(gncls.MyStatic/f "me") ; should print "Hi me from f"
(. gncls.MyStatic f "me") ; should print "Hi me from -f"

a/b both means function b in ns a and static method b in class a, when you have 
both a ns and a class going by the same name the ns wins.

Christophe






-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (en)



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

Reply via email to