On Jan 24, 5:05 pm, joel r <cirqu...@gmail.com> wrote:
> It's meant to be called like this:
> (define-template some-template-name
>   page some-function-1
>   posts some-function-2
>   post some-function-3)
>
> It defs a var called some-template-name bound to a map that looks like this:
> {:page some-function-1
>   :posts some-function-2
>   :post some-function-3}

Then perhaps:

(defmacro define-template [name & args]
  `(def ~name
     (hash-map ~@(mapcat (fn [[k v]] [(keyword k) v]) args)))

But honestly, I'm not sure I see the point. The macro doesn't make the
code particularly more concise, and the code is less clear now it uses
a custom macro, rather than using a standard hash-map.

I'd personally favour this:

(def foobar
  {:page  some-function-1
   :posts some-function-2
   :post  some-function-3})

Over this:

(define-template foobar
  page  some-function-1
  posts some-function-2
  post  some-function-3)

The former is a lot clearer to read, as it uses standard Clojure
datastructures.

- James

-- 
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

Reply via email to