If I understand correctly it could be implemented with the following change to Reflector.java: static Object boxArg(Class paramType, Object arg){ if(paramType.isInterface() && arg instanceof IFn) return makeAProxy( findMethodMatch( paramType, arg ), arg );
Which would then allow us to instead of using proxy: > (.addMouseListener > (proxy [MouseAdapter] [] > (mouseClicked [event] > (if (= 2 (.getClickCount event)) > (display-details (.locationToIndex (.getPoint event))))))) Write it using a function which will discover what interface/method to create a proxy for: (.addMouseListener #(if (= 2 (.getClickCount %)) (display-details (-> % .getPoint .locationToIndex))) something) The alternative solution for doing that if we are willing to create a macro or helper function: (defmacro add-action-listener "Attaches an ActionListener to a Component" [#^java.awt.Component obj, evt & body] `(.addActionListener ~obj (proxy [java.awt.event.ActionListener] [] (actionPerformed [~evt] ~...@body)))) (add-action-listener something evt (if (= 2 (.getClickCount evt)) (display-details (-> evt .getPoint .locationToIndex)))) The only difference being of course that you'd need a separate helper for all the different interfaces want to proxy, and would have to explicitly choose which interface the function implements. I don't have enough experience to know of how many anonymous single function interface proxies are useful. Regards, Tim. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---