On Thu, Dec 15, 2011 at 2:16 PM, Alan Malloy <[email protected]> wrote:
> FWIW, much safer is
>
> (defmacro dc
>  [sql-cmd]
>  `(sql/with-connection db
>     ~sql-cmd))
>
> If you use the version with (list) and plain-quoting of the first two
> items, then the namespace resolution is very fragile: it will only
> work if the caller has referred to the sql library with the prefix
> sql/, and if they have the db in scope. The syntax-quote expands those
> to their fully-qualified names, so that they always refer to the thing
> you intend, even if (god forbid) the user has an unrelated local
> variable named db in their lexical scope.

Yes, I know. I assumed the OP was going through an exercise that
introduces macros first, and then syntax-quote, rather than both at
once (or syntax-quote first).

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to