This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: importing java packages
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/