The reason why the macros don't work is that in both cases the value for the params
argument is the symbol params
. This is why in add-where-conditions-2
and add-where-conditions-3
when the macros make the call (make-conds params)
, the value that function receives is not the list you are thinking of but the symbol params
, showing an error in the lines of:
IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol clojure.lang.RT.seqFrom (RT.java:505)
The first case works because the function receives the list (not the symbol) as the value for the params
argument, so eval
receives the list (where {:your-query nil} (or (between :freq [100 200]) ,,,))
, which is what the where
macro expects and knows how to handle.
The where
macro parses the expression in search of some predicates which it uses to build expressions. where*
, the function alternative, doesn't have that kind of functionality, so I can't think of an alternative to eval
for eating the cake and having it too.