Hi again,

On 9 Mrz., 09:23, Meikel Brandmeyer <m...@kotka.de> wrote:

> (defmacro query
>   [rec [lhs op rhs]]
>   (case op
>     'and `(-> ~rec (query ~lhs) .and (query ~rhs))
>     'eq  `(-> ~rec (.field ~(name lhs)) (.eq ~rhs))))

Here a short note, why a macro can be actually annoying:

If you write macro which expands into a query the above will break,
because the symbols are suddenly qualified. Or you have to use ~'and
and ~'eq all over the place. Otherwise the case won't work anymore.
You'd have to write the macro more robust like this:

(defmacro query
  [rec [lhs op rhs]]
  (case (name op)
    "and" ....
    "eq"  ....))

With functions you don't have to think about these effects.

Sincerely
Meikel

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