This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
New Kawa "Frequently Asked Questions" section
- From: Per Bothner <per at bothner dot com>
- To: "kawa at sourceware dot org" <kawa at sourceware dot org>
- Date: Sun, 13 Dec 2009 10:55:07 -0800
- Subject: New Kawa "Frequently Asked Questions" section
I added a new "Frequently Asked Questions" chapter to the
Kawa manual, starting with a section on define-alias.
This is only in SVN for now (specifically in doc/kawa.texi),
but will be on the web-site when 1.9.91 is out, which will
hopefully be soon. Until then, if people have suggestions
for things that belong there, now is the time ...
22 Frequently Asked Questions
*****************************
22.0.0.1 What is the equivalent of Java import?
...............................................
Kawa's `import' follows R6RS, so it is bit like Java's `import static
TypeName.*' (static-import-on-demand) declaration.
Kawa doesn't have a direct equivalent of Java's `import TypeName'
(single-type-import) declaration, but `define-alias' provides similar
functionality:
(define-alias StrBuf java.lang.StringBuffer)
This has the advantage that you can pick an arbitrary name as an
alias.
There is no direct equivalent to Java's `import PackageOrTypeName.*'
(type-import-on-demand) declaration, but you can alias a package:
(define-alias jutil java.util)
(define mylist :: jutil:List (jutil:ArrayList))
You can also use `define-namespace' to introduce an abbreviation or
renaming of a class name, but as a matter of style `define-alias' is
preferred.
--
--Per Bothner
per@bothner.com http://per.bothner.com/