Shorthand for Java
Per Bothner
per@bothner.com
Fri Dec 20 10:36:00 GMT 2002
Wen-Chun Ni wrote:
> I am wondering whether there is a way to shorten the references to
> Java objects in Kawa in general.
I recently checked in to cvs new support for "qualified names"
which (among more longer-term xml- and Common Lisp-related
advantages) make method invoction much more convenient. I hadn't
announced it yet, since I hadn't written documentation. However,
I just wrote some, and checked it info CVS. Here is the short NEWS
version; see the manual (kawa.texi) for more details:
You can use define-namespace to define "namespace aliases".
This is used for the new short-hard syntax for method invocation:
(define-namespace Int32 "class:java.lang.Integer")
(Int32:toHexString 255) => "ff"
(Int32:toString (Int32:new "00255")) => "255"
Alternatively, you can write:
(java.lang.Integer:toHexString 255) => "ff"
This feature is also available for XQuery - see
http://www.gnu.org/software/qexo/Extensions.html#Calling-Java-Methods
> In JScheme, the Java dot notations
> are preserved and efforts were made to make it natural from Java
> programmers' perspective.
I have mixed feelings about dot notation and how natural it is.
The Kawa "colon notation" has other advantages, including integration
with XML namespace concepts.
> I love Kawa very much because of its underlying generic framework
> and its emphasis on compilation. However, I have to sell the idea
> to colleagues for them to appreciate how easy it is to write in
> Scheme without making Java integration too difficult.
I hope this new feature will help.
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/
More information about the Kawa
mailing list