>
> ========================================================
> (def #^Object bar (proxy [Object] [ ] (foo [number] (* 3 number))))
> (def fooFn ((proxy-mappings bar) "foo"))  ;; kludge
>
>  ;; succeeds
> (def bar4 (fooFn bar 4))
>
> ;; fails with "No matching method found: foo for class
> clojure.proxy.java.lang.Object"
> (def bar7 (.foo bar 7))
> ========================================================
>
> Is there a way to do this simply?

Try:
(gen-interface
  :name org.bar.IFoo
  :methods [[foo [Integer] void]])

(def bar (proxy [IFoo] (foo [n] (* 3 n))))

Or you can use gen-class instead of gen-interface and implement Foo as
concrete class. Proxy will accept any method name you give him, but it
will expose only methods in class and interfaces it extends.

--
Krešimir Šojat
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
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