Hi Tassilo,

What you are saying makes sense. I am always a bit shy to using macros as I 
have not understood them completely yet and everytime I tried I got 
distracted fast enough to not get it.

So I just played a bit with it and I am failing already on the generation 
of the namespace.
I have this function:

(defn generate-ns [ns]
  (let [ns `(ns ~ns (:require [foo.bar :as bar]))]
    (clojure.pprint/pprint ns)))

And calling it like this: (generate-ns "foons") will return this:
(clojure.core/ns
 "foons"
 (:require [foo.bar :as leiningen.code-generator/bar]))

However, what I need is this:
(ns                    ;only ns here
 foons             ; a symbol
 (:require [foo.bar :as bar])) ; only bar

It seems like these are basics, still I struggle to get it right. 

Any help is appreciated, thanks, 
Sven

Am Mittwoch, 8. April 2015 15:50:13 UTC+2 schrieb Tassilo Horn:
>
> Sven Richter <sve...@googlemail.com <javascript:>> writes: 
>
> Hi Sven, 
>
> > I want to create clojure source files with some code and a namespace 
> > and everything else what is useful for some source code.  What I am 
> > looking for is a templating language for clojure code, is there 
> > something like this already? 
>
> The templating language for all lisps is syntax-quote with unquote and 
> unquote-splicing, isn't it? 
>
> So I'd write functions which create the contents of the to-be generated 
> source files as data structures, i.e., a function definition is a list 
> whose first element in the symbol clojure.core/defn etc, and then print 
> these data structures into a file, e.g., using clojure.pprint. 
>
> Bye, 
> Tassilo 
>

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to