I tried using proxy+ for one of the proxy implementations in clojure.core, but I ran into an issue where a "too many matching methods" got thrown at macroexpansion time. The proxy I tried to replicate was PrintWriter-on <https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_print.clj#L559-L581>. The exception-data contained two "write" methods that matched arity but didn't match param types. Repro below.
(require '[com.rpl.proxy-plus :refer [proxy+]])) (defn ^java.io.PrintWriter proxy+test [flush-fn close-fn] (let [sb (StringBuilder.)] (-> (proxy+ [] java.io.Writer (flush [this] (when (pos? (.length sb)) (flush-fn (.toString sb))) (.setLength sb 0)) (close [this] (.flush this) (when close-fn (close-fn)) nil) (write [this ^chars str-cbuf off len] (when (pos? len) (.append sb str-cbuf ^int off ^int len)))) java.io.BufferedWriter. java.io.PrintWriter.))) On Monday, January 13, 2020 at 11:47:06 AM UTC-5, Nathan Marz wrote: > > proxy+ is a replacement for Clojure's proxy that's faster and more usable. > proxy has a strange implementation where it overrides every possible method > and uses a mutable field to store a map of string -> function for > dispatching the methods. This causes it to be unable to handle methods with > the same name but different arities. > > proxy+ fixes these issues with proxy. Usage is like reify, and it's up to > 10x faster. > > *Repository: *https://github.com/redplanetlabs/proxy-plus > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/bfd8e45a-4843-4422-b47f-3303ce53364e%40googlegroups.com.