On Fri, Feb 4, 2011 at 11:24 PM, Eugen Dück <eu...@dueck.org> wrote:
> I'm using a macro that, stripped down to just expose my problem, looks
> like this:
>
> (defmacro quoted-param
>  [x]
>  `(println '~x))
>
> It's all nice if I call it like
>
> (quoted-param 23)
>
> It will print the number 23. The following, however, will print
> "asdf", rather than 23:
>
> (def asdf 23)
> (quoted-param asdf)
>
> Which is of course what the quote is supposed to do. But is there any
> way to get that macro to expand to using the value of asdf, rather
> than the symbol itself? Or can only changing the macro fix this? I
> fear the latter, which would imply that using quotes like that in a
> macro should be done with great care, I guess. Adding a quote when
> 'calling' the macro is easy...

Why not just ~x rather than '~x? If you want the param evaluated, you
normally just unquote it with ~.

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