Milinda if you are asking about the ~' that simply allows you to quote a 
symbol without the namespace resolution that a backquote ` provides. If you 
are trying to capture a local lexical value or otherwise do not want the 
full namespace resolved for the symbol, then you must use an ordinary quote 
on the symbol since part of the job of a backquote is to provide the 
namespace resolution.

On Thursday, March 6, 2014 1:37:24 AM UTC+8, milinda wrote:
>
> Thanks Konrad. Your unquoting trick worked. But I am not exactly sure how 
> to reason about these types of situations. Can you please shed some lights 
> behind the logic of above unquoting if possible.
>
> Thanks
> Milinda
>
> On Wednesday, March 5, 2014 8:33:03 AM UTC-5, Konrad Hinsen wrote:
>>
>> --On 4 Mar 2014 23:07:27 -0800 milinda <milinda....@gmail.com> wrote: 
>>
>> > I wanted macro to work like following. 
>> > 
>> > 
>> > (ffff (let [x 10] (+ x (defpop)))) 
>> > 
>> > 
>> > This should generate function like 
>> > 
>> > 
>> > (defn execute [tu3455] (let [x 10] (+ x tu3455))) 
>>
>> Try this: 
>>
>>   (defmacro ffff [body] 
>>     `(macrolet [(~'defpop [] 'tu#)] (defn execute [tu#] ~body))) 
>>
>> In action: 
>>
>>   user=> (macroexpand-1 '(ffff (let [x 10] (+ x (defpop))))) 
>>   (clojure.tools.macro/macrolet [(defpop [] (quote tu__818__auto__))] 
>> (clojure.core/defn user/execute [tu__818__auto__] (let [x 10] (+ x 
>> (defpop))))) 
>>
>>   user=> (macroexpand '(ffff (let [x 10] (+ x (defpop))))) 
>>   (do (def user/execute (fn* ([tu__818__auto__] (let* [x 10] (+ x 
>> tu__818__auto__)))))) 
>>
>>
>> Konrad. 
>>
>>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to