This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: importing java packages


On Thu, 17 Mar 2005 10:35:56 -0800, Chris Dean <ctdean@sokitomi.com> wrote:
> 
> > Feature request for your consideration:  import-java-package
> >
> > (import-java-package <java.awt>)
> > (import-java-package <javax.swing>)
> 
> I'm in the camp of using define-namespace, just because it seems more
> Scheme-ish to say:
> 
>          (root (JFrame:getContentPane f))
> 
> instead of
> 
> >        (root :: <Container> (invoke f 'getContentPane)))
> 
> YMMV.

My mileage varies quite a bit in this case.

define-namespace is only useful when you're invoking methods.  You
can't use it in any of the other places you use type tags.  You still
need type tags for calling field and static-field, declaring function
argument and return types, and declaring types on local variables.

Kawa's type-guesser doesn't always guess correctly, and my app is always
giving me warnings about no applicable methods for java.lang.Object.
You can't just drop the :: <Container> from the example above.

define-alias is closer to the right thing:

(define-alias <JFrame> <javax.swing.JFrame>)

Unfortunately you still have to write a *bunch* of these if you're
doing any significant SWT or Swing code.  You could stick them all
in a module -- hundreds of aliases that you include in every little
script you write.  Need I enumerate the disadvantages of this approach?

I'm very much in favor of a new special syntax for imports.  I don't 
care exactly how it looks.  This would work just as well for me:

(java-import "javax.swing.*")

-steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]