This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

creating classes at runtime


I'm looking for a way to create instances from classes defined in .scm files that are written at runtime.
Is there a recommended way to do this? I'm guessing that (load file) is the way, but it's behavior is surprising me.


I'm calling (load "foo.scm") and I thought that any define-simple-class in foo.scm would be available via Class.forName. But Class.forName("FooClass") throws ClassNotFoundException. I can, however, create a FooClass with (make <FooClass>). I also notice that if I rewrite and reload foo.scm, the (make <FooClass>) will create an instance of the new class. How does this work? I thought Java couldn't redefine a class once it was loaded?

Right now, I'm thinking I can instantiate the dynamically created class like this:

(write-scm-file file-name)
(load file-name)
(eval `(make ,class-name))

Is there a better way?

Rob


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]