Re: [ANN] proxy-plus: Faster and more usable replacement for "proxy"

2020-01-20 Thread Nathan Marz
Thanks. It doesn't currently use type hints to distinguish between multiple 
methods of the same arity. Opened an issue: 
https://github.com/redplanetlabs/proxy-plus/issues/1

On Monday, January 20, 2020 at 11:57:31 AM UTC-5, Ghadi Shayban wrote:
>
> 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 
> .
>  
> 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/aae86211-1bc6-41db-9122-291b48f81a18%40googlegroups.com.


Re: [ANN] proxy-plus: Faster and more usable replacement for "proxy"

2020-01-20 Thread Ghadi Shayban
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 
.
 
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.