This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
improved import syntax
- From: Per Bothner <per at bothner dot com>
- To: mikel evins <mevins at me dot com>, Kawa mailing list <kawa at sourceware dot org>
- Date: Tue, 29 Sep 2015 16:15:12 -0700
- Subject: improved import syntax
- Authentication-results: sourceware.org; auth=none
In an import form, you can now use a classname (ie. a symbol usually
with dots), instead of a list. I.e.:
(import org.example.Foo)
is equivalent to:
(import (org example Foo))
I don't remember if I announced the import-class form, but it's quite handy:
You can import multiple class from the same package with duplication:
(import (class java.util Map HashMap))
You can also rename it:
(import (class java.lang (StringBuilder StrBuf)))
The above is equivalent to:
(define-alias StrBuf java.lang.StringBuilder)
but with import-class you can import (and optionally rename) many classes
in a compact form.
You can combine the class clause with import's only, except, rename, and prefix clauses,
though only prefix is likely to be useful. For example:
(import (prefix (class java.lang Long Short) jl-))
is equivalent to
(import (class java.lang (Long jl-Long) (Short jl-Short)))
--
--Per Bothner
per@bothner.com http://per.bothner.com/