I want to have options in clojure file which I want to load from a
script. Script later will use global *input-config* to do its work.
;;;;;;;;;;;;;;;;;; c:\inputgen-config.clj
; Input configuration
(def *input-config*
{ :buy-vs-sell-length 1.0,
:shorter-length 10,
:min-price 0.0,
:max-price 100.0,
:fname "input.txt" })
;;;;;;;;;;;;;; inputgen.clj
(use 'clojure.contrib.command-line)
(defn -main [& args]
(with-command-line args
"Agruments spec for inputgen"
[[input-file "Input file with directions" "inputgen-config.clj"]]
(do
(println "Loading input file:" input-file)
(println (ns-interns *ns*))
(load-file input-file)
(println (ns-interns *ns*))
;(println *input-config*)
;(println #'*input-config*)
;(println #'user/*input-config*)
)))
(apply -main *command-line-args*)
Here is what it prints after called on Windows (clojure 1.2)
c:\tmp>clj.bat inputgen.clj --input-file "c:/inputgen-config.clj"
Loading input file: c:/inputgen-config.clj
{-main #'user/-main}
{*input-config* #'user/*input-config*, -main #'user/-main}
So, it appears that load-file works but I can't println *input-config*
(as seen by 3 commented lines). First one fails with
Caused by: java.lang.Exception: Unable to resolve symbol: *input-
config* in this context
at clojure.lang.Compiler.resolveIn(Compiler.java:5677)
at clojure.lang.Compiler.resolve(Compiler.java:5621)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:5584)
at clojure.lang.Compiler.analyze(Compiler.java:5172)
... 55 more
Any ideas what is going on?
--
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