This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Calling getClass() on a Scheme subclassed object
- From: Sean Luke <sean at cs dot gmu dot edu>
- To: kawa at sources dot redhat dot com
- Date: Mon, 29 May 2006 23:52:38 -0400
- Subject: Calling getClass() on a Scheme subclassed object
I maintain a simulation toolkit (MASON) in Java and have been
interested in seeing if I can get some simulation apps written in
Scheme rather than in raw Java. So far I've been successful, and
after heavily typing the scheme code, it runs at very close (about
1.5) the speed of my Java code. Not bad!
Unfortunately I'm stuck with a difficulty. In the system you
typically create a subclass of a Java class (sim.engine.SimState),
and then populate that class with various data to form your
simulation model. Let's say your simulation is called sim.app.Foo.
The most straightforward way to run your simulation is to then call
the following method:
doLoop(sim.app.Foo.class, ...)
In Scheme, I create the subclass using define-simple-class:
(define-simple-class <Foo> (<sim.engine.SimState>) ... )
But I am utterly stymied as to how to pass the "Class" for the <Foo>
scheme class into the doLoop method. For example, this works using a
preexisting Java simulation:
(<sim.engine.SimState>:doLoop <sim.app.tutorial1and2.Tutorial1>:class
(<java.lang.String[]> (*:toString "-help")))
But doing something like this:
(<sim.engine.SimState>:doLoop <Foo>:class (<java.lang.String[]>
(*:toString "-help")))
... fails because <Foo> isn't a class but is a
gnu.bytecode.ClassType, and the documentation is pretty scarce about
how (or if it's even possible) to extract the class proper out of
this beast. Ideas?
Sean