I've followed the directions at
http://java.ociweb.com/mark/clojure/article.html#Compiling to compile
a simple clojure app. In my base directory, I have a dir called
classes, and another called src. I am attempting to follow Richard
Newman's advice in the thread called "newbie question: splitting up
source files", by having one namespace dedicated to each source file.
;;;; src/foo/main.clj
(ns foo.main (:gen-class) (:use foo.util))
(defn a [caller]
(println (str "a called by: " caller)))
(defn -main [greetee]
(println (str "Hello " greetee "!"))
(a "-main")
(b "-main"))
;;;; src/foo/util.clj
(ns foo.util (:use foo.main))
(defn b [caller]
(println (str "b called by: " caller))
; the following line won't compile, throws
; java.lang.Exception: Unable to resolve symbol: a in this context
(a "b")
)
Then I do:
java -cp src;classes;lib/clojure.jar clojure.main compile.clj
which invokes "(compile 'foo.main)". I then get "java.lang.Exception:
Unable to resolve symbol: a in this context". How can I set up my
project so that from any given namespace, I can call functions from
any other namespace in the project? Note that if I comment out the
offending line, my app compiles and runs just fine when I invoke e.g.:
java -cp classes;lib/clojure.jar foo.main abcdef
Can anyone straighten me out?
Another thing I've noticed is that even during compilation, the order
that functions are definied in a source file matter. That makes sense
to me when a clj file is run as a script, but when clojure code is
getting compiled, why should it matter which order things are defined
in? Is this behavior related somehow to my compilation error?
Thanks, Mike
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en