On Wed, Feb 2, 2011 at 1:48 AM, George Jahad
<cloj...@blackbirdsystems.net> wrote:
> As usual, Meikel has the right answer.  But I didn't quite get it at
> first.
>
> It looks like syntax-quote generates cons's, not lists:
> user> (type (nth `(handler-case :type (println "test") (~'handle foo))
> 3))
> clojure.lang.Cons
>
> Your macroexpand-1 example worked because the reader doesn't
> distinguish between cons's and lists.
>
> Because handler-case is expecting a list and syntax-quote won't
> generate one

This also means that macros should not use list? to test whether an
object is a nonatomic s-expression. Unfortunately core doesn't contain
a compact test for atomicity; to get all the list-y things that print
as (foo bar baz ...) you can use something like

(and
  (coll? x)
  (not (or (vector? x) (map? x) (set? x)))

which should return logical true only when x is list-y. Wrap that in a
predicate function and use it in your macros in place of list?.

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