--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
This is what Sunil is talking about:
http://en.wikipedia.org/wiki/Common_Lisp#Variable_capture_and_shadowing
The "symbol#" string is a part of how syntax-quote works. Read
http://clojure.org/reader#The Reader--Macro characters
On Mon, Nov 8, 2010 at 10:12 AM, Sunil S Nandihalli
--
Cheers,
Leif
session will be fully qualified. this is the default behavior.
If you really want it, then you can treat it as the result of the
unquoting of a value which resolves to a symbol.
So you'll use ~ to say you want the value of .... (quote session)
(quote session returns the symbol session when evaluated).
that is, use ~'session instead of just session.
HTH,
--
Laurent
2010/11/8 Miki <miki....@gmail.com>:
Ugh.
What you really want in this case is a binding. Try this:
(defmacro def-dispatcher-test [test-name state command session-sym & body]
`(deftest ~test-name
(let [~session-sym (test-session ~state)]
(dispatcher ~command ~session-sym)
~@body)))
(def-dispatcher-test user-test :authorization "USER bugs" session
(is (= (:user @session) "bugs"))
(is (= (get-one session) "+OK Hello bugs\n")))
The added parameter just before the body specifies a name to bind the
session object to; this name can then be used in the body.
Yes, those are the two choices. Ken's suggestion is the cleanest, and
you definitely should do that in cases where it's not burdensome.
Here, where it's a macro for private testing, and you are certain not
to forget that it's magically binding session for you, then go ahead
and use Laurent's suggestion to create bindings.
On Nov 8, 11:38 am, Miki <miki.teb...@gmail.com> wrote:
> >> that is, use ~'session instead of just session.
> > What you really want in this case is a binding. Try this:
> > ...
> > The added parameter just before the body specifies a name to bind the
> > session object to; this name can then be used in the body.
>
> This is good a well, but I prefer to dark magic suggested by Laurent :)