On Mar 21, 6:13 pm, ronen <nark...@gmail.com> wrote:
> Hello there,
> Iv been trying to implement a proxy on a class 
> (http://code.google.com/p/javaparser/source/browse/trunk/JavaParser/sr...)
> that has multiple overloaded methods (same arity different types),
> trying
>
> (defn create-visitor []
>   (proxy [VoidVisitorAdapter] []
>     (visit [method, arg]
>       (println method))
>     (visit [exp, arg]
>       (println type))))
>
> This results with compilation error Caused by:
> java.lang.IllegalArgumentException: Method 'visit' redefined.
>
> Type hints didn't help either:

Proxy doesn't care about argument types.  You need one method with a
conditional:

(defn create-visitor []
  (proxy [VoidVisitorAdapter] []
    (visit [arg1 arg2]
      (if (instance? MethodDeclaration arg1)
         ...))))

You could also define a multimethod and call it from the proxy.

-Stuart Sierra
--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to