On Nov 17, 8:50 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> On Nov 16, 2008, at 10:34 PM, Rich Hickey wrote:
>
> > Since it only requires main, might I suggest you write this in
> > Clojure instead?
>
> I gave that a try.
>
> Here's a simple version of a driver for the compiler, stored in src/
> clj/clojure/compile.clj:
>
>         (ns clojure.compile)
>
>         (defn main
>           "Compiles libs into class files stored at compile-path.
>           All args are strings"
>           [compile-path & libs]
>           (printf "Compiling %d libs to %s\n" (count libs) compile-path)
>           (flush)
>           (binding [*compile-path* compile-path]
>             (doseq [lib libs]
>                 (compile (symbol lib)))))
>
> It works when run from within the Clojure repl:
>
>         % ls build/classes/clojure/hello*
>         ls: build/classes/clojure/*hello*: No such file or directory
>         % java -cp clojure.jar:src/clj/ clojure.lang.Repl
>         Clojure
>         user=> (require 'clojure.compile)
>         nil
>         user=> (clojure.compile/main "build/classes" "clojure.hello")
>         Compiling 1 libs to build/classes
>         nil
>         user=>
>         % ls build/classes/clojure/hello*
>         build/classes/clojure/hello$main__8.class       build/classes/clojure/
> hello.class
>
> but when run as a standalone main, it gives an exception that appears
> to be related to static initializers:
>
> % java -cp clojure.jar:src/clj/ clojure.compile build/classes
> clojure.hello
> Compiling 1 libs to build/classes
> Exception in thread "main" java.lang.IllegalStateException: Var null/
> null is unbound. (hello.clj:3)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:4067)
>         at clojure.lang.Compiler.analyze(Compiler.java:3896)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:4050)
>         at clojure.lang.Compiler.analyze(Compiler.java:3896)
>         at clojure.lang.Compiler.access$100(Compiler.java:38)
>         at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:365)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:4060)
>         at clojure.lang.Compiler.analyze(Compiler.java:3896)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:4050)
>         at clojure.lang.Compiler.analyze(Compiler.java:3896)
>         at clojure.lang.Compiler.analyze(Compiler.java:3869)
>         at clojure.lang.Compiler.compile(Compiler.java:4498)
>         at clojure.lang.RT.compile(RT.java:408)
>         at clojure.lang.RT.load(RT.java:450)
>         at clojure.lang.RT.load(RT.java:422)
>         at clojure.core$load__4423$fn__4425.invoke(core.clj:3343)
>         at clojure.core$load__4423.doInvoke(core.clj:3342)
>         at clojure.lang.RestFn.invoke(RestFn.java:413)
>         at clojure.core$load_one__4386.invoke(core.clj:3189)
>         at clojure.core$compile__4429.invoke(core.clj:3347)
>         at clojure.compile$main__5162.doInvoke(compile.clj:23)
>         at clojure.lang.RestFn.invoke(RestFn.java:428)
>         at clojure.lang.Var.invoke(Var.java:323)
>         at clojure.lang.AFn.applyToHelper(AFn.java:195)
>         at clojure.lang.Var.applyTo(Var.java:436)
>         at clojure.compile.main(Unknown Source)
> Caused by: java.lang.IllegalStateException: Var null/null is unbound.
>         at clojure.lang.Var.get(Var.java:129)
>         at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2947)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:4058)
>         ... 25 more
> %
>
> For reference, here is the test compilee: src/clj/clojure/hello.clj:
>
>         (ns clojure.hello)
>
>         (defn main
>           [greetee]
>           (printf "Hello, %s wow\n" greetee)
>           (flush))
>
> I'd appreciate help in getting a standalone invocation of something
> like compile.clj above (i.e., using it's own main without Repl or
> Script) to work.
>
> In working through this, I also found that a compiler driver written
> in Java may be preferable for use via build.xml because of a bootstrap
> problem. Until we compile (something like) "compile.clj", we can't
> call it as a standalone main. (One could add a step that builds the
> compiler driver via a clojure.lang.Script invocation.)
>


Fixed (SVN 1108) - thanks for the report.

Rich

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to