So, I have build a library which allows me to generate logic statements,
which can then be computing over. So:
(defclass A)
(defclass B :subclass A)
which means, all instances of B are also instances of A. defclass is
implemented with a macro which underneath expands to a def form. The
vars in this case (A and B) hold Java objects representating these
statements.
These statements can be saved in an XML representation called OWL, which
is a W3C standard. Most of the people generating OWL files are not using
my library; so I need to be able to read these OWL files and interact
with them in manner which is similar to if I had written them with my
library. So I parse the XML file, generate some Java objects, then
use intern to generate vars. So, now I can refer to an OWL file in
exactly the same way as if it were written in Clojure. All of this
works, except for the problems I have had with testing I cannot load
vars on the fly.
I have a related problem when I want to test a renderer that I have
written which generates clojure code (again, representing logical
statements). After rendering the Clojure, I then run a require the
rendered code. Nice idea, but fails -- you can see an exemplar of the
problem here:
user=> clojure.set/difference
CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)
user=> (do (require 'clojure.set) clojure.set/difference)
#<set$difference clojure.set$difference@6ee76fcc>
(restart repl)
user=> clojure.set/difference
CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)
user=> (try (require 'clojure.set) clojure.set/difference)
CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:2:1)
In the end, my work around was equivalent to this...
(try (require 'clojure.set) (eval 'clojure.set/difference))
#<set$difference clojure.set$difference@63ae6098>
Tell me if all this is making you feel queasy. In either circumstance,
the code *should* run, although I understand why it does not. This
strong separation of undynamic compilation and a dynamic eval seems
unnatural to me.
Anyway, I do have a work-arounds to be going on with, and I suspect that
it's not going to change because it's depths of clojure stuff.
Phil