On Sun, Jan 30, 2011 at 1:47 PM, Jonas Enlund <jonas.enl...@gmail.com> wrote: > user=> (.write text-area-writer "Hello, World!") > ArityException Wrong number of args (2) passed to: user$fn--38$fn > clojure.lang.AFn.throwArity (AFn.java\ > :439) > user=> (pst) > ArityException Wrong number of args (2) passed to: user$fn--38$fn > user.proxy$java.io.Writer$0.write (:-1) > sun.reflect.NativeMethodAccessorImpl.invoke0 > (NativeMethodAccessorImpl.java:-2) > sun.reflect.NativeMethodAccessorImpl.invoke > (NativeMethodAccessorImpl.java:57) > sun.reflect.DelegatingMethodAccessorImpl.invoke > (DelegatingMethodAccessorImpl.java:43) > java.lang.reflect.Method.invoke (Method.java:616) > clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:90) > clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28) > user/eval47 (NO_SOURCE_FILE:4) > clojure.lang.Compiler.eval (Compiler.java:6223) > clojure.lang.Compiler.eval (Compiler.java:6190) > clojure.core/eval (core.clj:2680) > clojure.main/repl/read-eval-print--5617 (main.clj:180) > nil > user=>
The proxy documentation says If a method fn is not provided for a class method, the superclass methd will be called. This doesn't seem to work if you override one of several overloads of a method. The documentation should probably be clarified to reflect that this isn't the case for overloads of a method you have overridden; it seems you have to supply one function (overloaded for arity) that implements all of the overloads, as that one function will be called for all of the overloads. This proxy works: (proxy [java.io.Writer] [] (close []) (flush []) (write ([chrs offs len] (if (string? chrs) (.append text-area (subs chrs offs (+ offs len))) (.append text-area (String. ^chars chrs offs len)))) ([thing] (.append text-area (str thing)))))) The second arity handles all the overloaded .write methods with only one parameter, and the first handles the String offset length and Char-Array offset length overloads. > Thanks for helping out with this Ken! You're welcome. -- 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 Note that posts from new members are moderated - please be patient with your first post. 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