Hi Tomas,

> >   http://rosettacode.org/wiki/Animation#Java.2FSwing
> ...
> I like the plain text version:-D

Yes, me too. That's the most PicoLisp-like one in my feeling :)


> I have implemented this example using my wl interpreter and added it
> into the git repository under the name swing9.l so that you can compare.

Thanks. If I start it with (load "swing9.l"), it shows the window with
the text, but it doesn't scroll. It seems that the actual scroll logic
is missing.


> >    (java Button "addActionListener"
> >       (interface "java.awt.event.ActionListener"
> >          'actionPerformed
> >          (curry (Button Frame) (Ev)
> >             (java Frame "hide")
> >             ...
> 
> Your 'interface' function has two restrictions:
> 
> 1) It can create proxy instance only for one interface while in Java,
>    one can create proxy instance for many interfaces.

No. The single interface argument is just for convenience. You can also
pass a list of interfaces

   (interface '("java.awt.event.ActionListener" ..)


> 2) It is not possible to create one handler for many events and be aware
>    of which event was invoked.

Why not? The event is passed in as an argument and can be inspected.



> Yes, that's a limitation of Swing.  If Swing was better designed, it
> would not be an issue.
> 
> > The limitation of not being able to define a "class" proxy is more one
> > of the JVM Proxy than just of Swing, it seems.
> > Proxy.newProxyInstance() doesn't accept a normal class, just an
> > interface.
> 
> Yes, shame.  I briefly looked at how Clojure implements proxy (it
> supports both interface and class proxy) and it seems it just compiles a
> new class for it instead of going through the dynamic proxy option.

I suspected so. But I don't want to go such far. For Clojure this is
natural, as it compiles bytecodes anyway.

Cheers,
- Alex

-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to