This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Kawa Generic Functionality
- From: Nigel Dolby <nigel_dolby at acm dot org>
- To: 'Kawa List' <kawa at sources dot redhat dot com>
- Date: Tue, 21 Feb 2006 09:15:24 -0600
- Subject: Kawa Generic Functionality
As I port Common Lisp code into Kawa there are a number of things that
would make the process easier, and it would be nice to know if there are
ways to do these and what they are.
1. The Common Lisp function TYPE-OF accepts absolutely any object and
returns its type as a symbol; this includes CLOS objects, for which the
CLOS class is returned. I have written a Kawa function that partially
implements TYPE-OF by explicitly checking for string, integer, etc in a
COND, but is it possible also to reliably obtain the type of objects
defined with DEFINE-SIMPLE-CLASS and of Java objects (without knowing
that the object in question actually is such a class)?
2. CLOS classes can be given a PRINT-OBJECT method which allows
customization of the displayed form of an object of that class. I have
tried attaching a toString method to Kawa classes (made with
DEFINE-SIMPLE-CLASS) but this doesn't produce the same effect; is there
a way to do so?
3. I have a function called COPY-CLOS-INSTANCE which clones a given
instance, optionally using COPY-TREE on any lists it contains. It
operates by creating a new object and copying each existing slot value
from the old to the new object. I need this in Kawa. I first tried to
use the Java 'clone' method, but this generated a protection error at
compile time. I find that I can obtain the fields of an instance in Kawa
by invoking getClass followed by getFields, but I have not found any
definition of the Field objects that are returned. So my code currently
invokes toString on the Field objects and unmangles the last part of the
returned string to get the Field name. Is there a more elegant way to do
this?
4. When a piece of code breaks and control returns to the Kawa
interactive window, a backtrace is provided that (usually) locates very
closely the offending source line; is it possible at that point to
inspect the local variables?
Thanks.
Nigel Dolby.