This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: importing java packages
- From: S D <s dot mailinglists at gmail dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: Chris Dean <ctdean at sokitomi dot com>, Steve Yegge <steve dot yegge at gmail dot com>, kawa at sources dot redhat dot com
- Date: Fri, 8 Apr 2005 15:56:32 -0800
- Subject: Re: importing java packages
- References: <d494cb8f050316212611846b5b@mail.gmail.com> <m2sm2uf7cj.fsf@tungsten.mercedsystems.com> <4239D582.4070607@bothner.com>
- Reply-to: S D <s dot mailinglists at gmail dot com>
I was going through BeanShell documentation and found that they seem
to support importing of package classes in their interpreter.
http://www.beanshell.org/manual/syntax.html#Importing_Classes_and_Packages
On Mar 17, 2005 11:07 AM, Per Bothner <per@bothner.com> wrote:
> Chris Dean wrote:
> > How about this alternate feature:
> >
> > (define-package-namespaces <java.awt>)
> >
> > which would create (define-namespace JFrame <java.awt.JFrame>) etc.
>
> As Dominique mentions, this doesn't work because there is no practical way
> (as far as I know) to enumerate all the classes in a package.
>
> > What I really would like is if Kawa provided me the tools so I could
> > write this feature in Scheme myself with access to the compiler source
> > code.
>
> If there were a way to enumerate the classes in a package, then one
> could write a syntax-case macro for define-package-namespaces.
>
> Instead, we'd need a way to modify the search order of <NAME> and/or
> PREFIX:NAME. It might be a useful extension to translate identifier
> patterns. This would be a generalization of identifier macros,
> but allowing patterns:
>
> (define-token-matcher awt.* token
> (if (exists-class? token)
> (datum->syntax-object (string-append "<java." token ">"))
> #f))
>
> Don't expect this anytime soon ... Special-case syntax will be
> easier, at least in the short run. Perhaps:
> (define-namespace * "class:java.awt.*")
> or:
> (define-namespace util.* "class:java.util.*")
>
> The latter would allow e.g. util.List:iterator.
> --
> --Per Bothner
> per@bothner.com http://per.bothner.com/
>