Thank you everyone for explanations. I think now I understand macros and
how to use macro let better.
Milinda
On Thursday, March 6, 2014 1:51:59 PM UTC-5, Konrad Hinsen wrote:
>
> --On 5 Mar 2014 09:37:24 -0800 milinda >
> wrote:
>
> > Thanks Konrad. Your unquoting trick worked. But I am not e
--On 5 Mar 2014 09:37:24 -0800 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.
I suppose you refer to the ~'defpop, right? That
Hi, Milinda. I'll try to explain my reasoning of the situation. I always
find it helpful to macroexpand if I'm having trouble:
;; original version
user=> (macroexpand-1 '( boby))
(clojure.tools.macro/macrolet [(defpop [] tu1282)] ;; <- undef. lookup
(clojure.core/defn user/execute [tu12
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 quot
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
--On 4 Mar 2014 23:07:27 -0800 milinda wrote:
I wanted macro to work like following.
( (let [x 10] (+ x (defpop
This should generate function like
(defn execute [tu3455] (let [x 10] (+ x tu3455)))
Try this:
(defmacro [body]
`(macrolet [(~'defpop [] 'tu#)] (defn execute
I tried this. But couldn't achieve what I wanted. Below is the macro I
wrote by utilizing macro let
(defmacro [body]
(let [x (gensym 'tu)
defpop-decl
(list 'defpop [] x)]
`(macrolet [~defpop-decl]
(defn execute [~x] ~body
I wanted macro to work like
Thanks Jason. I'll try this.
Milinda
On Tuesday, March 4, 2014 1:35:39 PM UTC-5, Jason Felice wrote:
>
> Can you use macrolet from here: https://github.com/clojure/tools.macro ?
>
>
> On Tue, Mar 4, 2014 at 11:30 AM, milinda
> > wrote:
>
>> I wanted to achive following inside a macro. Lets say
Can you use macrolet from here: https://github.com/clojure/tools.macro ?
On Tue, Mar 4, 2014 at 11:30 AM, milinda wrote:
> I wanted to achive following inside a macro. Lets say I have a macro
> called deffilter which can use in following manner.
>
> (deffilter split-sentence ["sentence"] ["word"