Hi, On 30 Okt., 00:31, ntupel <[EMAIL PROTECTED]> wrote: > Consider the following code which attempts to redefine clojure/*out*: > (def output-stream > (let [buffer (new java.io.ByteArrayOutputStream)] > (proxy [java.io.OutputStream] [] > (flush [] > (.append output (.toString buffer "UTF-8")) > (.reset buffer)) > (write [x] > (when (>= (.size buffer) 32) > (.flush this)) > (.write buffer x)) > (write [x off len] > (.write buffer x off len))))) > ... > However if I omit the second write method in the proxy definition, > I get the following error:
I think the problem here the second write. The syntax should be the same as for defns. (def output-stream (let [buffer (new java.io.ByteArrayOutputStream)] (proxy [java.io.OutputStream] [] (flush [] (.append output (.toString buffer "UTF-8")) (.reset buffer)) (write ([x] (when (>= (.size buffer) 32) (.flush this)) (.write buffer x)) ([x off len] (.write buffer x off len)))))) I'm not sure what happens in your case, but my suspicion is, that the second overwrites the first, or that it may be equivalent to this form. However when you new remove the second form, there is still a write method! However this one takes the wrong number of arguments. Hence the method of the super class is not called and you get the Exception. But proxy-super to the rescue: You may try the following snippet for the write method: (write ([x] (when (>= (.size buffer) 32) (.flush this)) (.write buffer x)) ([x off len] (proxy-super write x off len))) Since there is a write method, we have to call the super-class' method explicitely. Hope this helps. Sincerely Meikel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---