Hi guys,

Am I missing something here?

We define SWING listeners with proxies and find that it's already short
in terms of code lines:

(.addMouseListener
  (proxy [MouseAdapter] []
    (mouseClicked [event]
        (if (= 2 (.getClickCount event))
                (display-details (.locationToIndex (.getPoint event)))
        )
    )
  )
)

Does the removal of the proxy call warrants significant efforts to
implement a "transparent" way of calling Java code ?
For us most of the programming time is spent in looking at the Javadoc
of the Java code to find which interface to use and how, not typing the
proxy call
itself.
Hope you do not hit too many member functions with the same name and
number of arguments but with different classes/interfaces :)))
You would then now a way to solve the ambiguity...

Again did I miss something ?

Luc



On Tue, 2009-09-01 at 00:59 +0200, Christophe Grand wrote:

> Rhino provides a similar facility
> https://developer.mozilla.org/en/Scripting_Java#JavaScript_Functions_as_Java_Interfaces
> but AFAIK it uses reflection.
> 
> On Tue, Sep 1, 2009 at 12:03 AM, Kevin Downey<redc...@gmail.com> wrote:
> >
> > I think this would necessitate an added layer of indirection and
> > reflection, which would mean taking a performance hit.
> >
> > On Mon, Aug 31, 2009 at 2:54 PM, Stuart
> > Sierra<the.stuart.sie...@gmail.com> wrote:
> >>
> >> That's a clever trick.  How does the block know which interface method
> >> was invoked?
> >> -SS
> >>
> >> On Aug 31, 2:41 pm, rb <raphi...@gmail.com> wrote:
> >>> Hi,
> >>>
> >>> After using Jwt from Clojure, I did it with Jruby and discovered that
> >>> Jruby has what they call Closure Conversion (http://kenai.com/projects/
> >>> jruby/pages/CallingJavaFromJRuby#Closure_conversion ) where a Ruby
> >>> block or closure is converted to an appropriate Java interface. From
> >>> the wiki: "When calling a method that expects an interface, JRuby
> >>> checks if a block is passed and automatically converts the block to an
> >>> object implementing the interface".
> >>>
> >>> I found this to be unbelievably easy to use and efficient (for the
> >>> developer) as the listener is added this way:
> >>> button.clicked.add_listener(self) do
> >>>   greeting_.setText(nameEdit_.getText)
> >>> end
> >>>
> >>> There's no need for the developer to implement any interface or manage
> >>> any proxy object.
> >>> I wondered if something similar is possible in Clojure. If not, would
> >>> this be considered a valuable addition to Clojure?
> >>>
> >>> Thanks
> >>>
> >>> Raphaël
> >> >
> >>
> >
> >
> >
> > --
> > And what is good, Phaedrus,
> > And what is not good—
> > Need we ask anyone to tell us these things?
> >
> > >
> >
> 
> 
> 

Luc Préfontaine

Armageddon was yesterday, today we have a real problem...

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to