This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
query type of an instance
- From: John Whittaker <john dot whittaker at sbcglobal dot net>
- To: kawa at sourceware dot org
- Date: Thu, 13 Dec 2007 15:23:05 -0800 (PST)
- Subject: query type of an instance
Hi Kawa users!
I wish to begin by saying I am really starting to love
Kawa! Having all of the Java libraries available in
Scheme and being able to subclass is a powerful and
wonderful combination. Add in the nifty SchemeScript
plugin in Eclipse and the development environment is
really great.
Now my newest newbie question... I hope I am not
missing something obvious. How do you query the type
of an object? I know about instance?, but if I knew
enough about an object's type to use instance? I would
have half my answer :). For example, if I have an
instance of sun.jdbc.odbc.JdbcOdbcResultSet, what
function can I call with that instance which returns
the class sun.jdbc.odbc.JdbcOdbcResultSet?
Finally, what all this is really leading up to is a
bigger Kawa and Scheme macro question. I'd like to
have a macro (maybe a function would do as well)which
I will call "with-result-set" (perhaps
"collect-result-set" would be better). You would give
it a result set instance (say a
sun.jdbc.odbc.JdbcOdbcResult) and a variable number of
pairs consisting of a type and a field name. So an
invocation might look like (with-result-set my-rs
'(String "Field1") '(Float "Field2") ...). It would
return a list of lists of all those fields in the
result set: (("abc" 42) ("def" 56.2) ...).
I'm really green on syntax-case etc. I think it
should be possible to do this, and perhaps using a
macro if the types are known at compile time. Any
thoughts?
Is there a function analogous to macro-expand in Kawa?
Thanks,
John Whittaker