This is the mail archive of the kawa@sourceware.org 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]

improved import syntax


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/


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