Well it seems to be more complicated than that,  defining a visit
method overrides the call to the visit(CompilationUnit n, A arg)
method which contains the basic visitation logic, what that
I actually need is a way of overriding specific methods (like the visit
(MethodDeclaration n, A arg) and not all of them.
My best guess is that I should somehow manually map the proxy methods.




On Mar 22, 6:19 pm, Stuart Sierra <the.stuart.sie...@gmail.com> wrote:
> 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