Stephen, You are absolutely right, and I hope to have all your syntax suggestions implemented tomorrow.
By way of background: When I started, it seemed there were three obvious avenues to pursue: (1) write a Clojure DSL that generates the Ant XML (2) write a Clojure DSL that sticks close to the underlying Ant object model (3) stick to Clojure idioms and use individual Ant classes when they fit in I rejected #1 out of hand--I don't think that the Ant XML has value, and so wrapping it (and having it leak in the form of error messages) was unappealing. I picked #2 because I thought there were a ton of objects in the Ant model I would end up wanting, and that they would be so intertwined that I would need to use most of them in order to use any of them. A few hours working on #2 was enough to convince me that there not much in Ant that I wanted to keep. In particular targets, properties, and subtask elements aren't worth their weight. That leaves only tasks (and a stubbed-out project object). So now I am proceeding through door #3. The work on #2 wasn't a total waste -- I now know enough of the Ant object model to fake out the few things I need (so far). Cheers, Stuart > On Thu, Nov 06, 2008 at 01:48:43PM -0500, Stuart Halloway wrote: >> >> Hi all, >> >> I am playing around with using Clojure to control Ant, something >> along >> the lines of Groovy's Gant. I don't know how far I will take this-- >> right now it is serving as a code example for the book. >> >> Two questions: >> >> (1) Anybody interested in seeing lancet carried forward into a real >> project? > > Oh yes please! I had started playing around with something like > this, got > far enough to compile some Java source (a static base for some > Clojure code > of course), and haven't really touched it sense. > >> (2) Below is an example of lancet syntax (compare with Clojure's own >> build.xml). Any big likes/dislikes? > > I've never liked XML DSLs because they lack standard general purpose > language features and go on to invent their own ad-hoc versions. > > Is a property not just a 'def' ? > > Is a target not a just function? (which only performs its actions if > needed) > > Isn't a project just a mapping from target names to functions, and > dynamic > bindings during the build process? > > > ; properties > (def src "src") > (def jsrc (str src "/jvm")) > (def cljsrc (str src "/clj")) > (def target "classes") > (def clojure.jar "clojure.jar") > (def bootclj (str cljsrc "/clojure/boot.clj")) > > ; deftarget is like defn but takes no args, and wraps the body in > machinery > ; that will only call it once per session. > > (deftarget clean > "Remove autogenerated files and directories" > (delete :dir target)) > > (deftarget init > (tstamp) > (mkdir :dir target)) > > (deftarget compile-java > "Compile java sources" > (init) > (javac :srcdir jsrc :destdir target > :includejavaruntime true > :debug true > :target "1.5")) > > > A project could be defined explicitly, or could be created through > reflection (deftarget would also add some metadata in that case) > > This syntax seems Clojurish rather than happens-to-be-on-Clojure. I > think it > shows off both the cognitive simplicity of FP and the powerful > incremental > nature of a Lisp based internal DSL. > > > Regards, > Steve > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
