Re: Macros and deftype – usage question

2012-04-29 Thread Baishampayan Ghose
The problem is in embedding an actual function object instead of a form which creates the function object. That results in a form which can't be read properly and thus the cryptic error. Regards, BG On Sat, Apr 28, 2012 at 9:13 PM, Shantanu Kumar wrote: > Hi, > > I am running into error when usi

Re: Macros and deftype – usage question

2012-04-28 Thread Shantanu Kumar
On Apr 28, 9:32 pm, Armando Blancas wrote: > Seems like the expansion is trying to put the function's value in there, > and this has already been compiled. If the function' code is expanded > in-place it works. True. Thanks for confirming this. Shantanu -- You received this message because y

Re: Macros and deftype – usage question

2012-04-28 Thread Armando Blancas
Seems like the expansion is trying to put the function's value in there, and this has already been compiled. If the function' code is expanded in-place it works. user=> (defmacro bar [a] (let [b (keyword a) f `(fn [& args#] ~b)] `(deftype ~a [] clojure.lang.ILookup

Re: Macros and deftype – usage question

2012-04-28 Thread Alex Baranosky
This macroexpansion looks fine to me... but still gives an error when you try to call (bar alex). (defmacro bar [a] (let [b (keyword a) f-gensym (gensym "f")] `(let [~f-gensym (fn [& args#] ~b)] (deftype ~a [] clojure.lang.ILookup (valAt [this# k#] (~f-gens

Re: Macros and deftype – usage question

2012-04-28 Thread Shantanu Kumar
> I had to play with this because it seemed like for some reason you were > trying to call it on my name :) I appreciate you chimed in, though the mention of your name was purely coincidental. :) > So far one thing I've isolated is that if you cut out the function calls it > will compile the macr

Re: Macros and deftype – usage question

2012-04-28 Thread Alex Baranosky
Hi Shantanu, I had to play with this because it seemed like for some reason you were trying to call it on my name :) So far one thing I've isolated is that if you cut out the function calls it will compile the macro: (defmacro bar [a] (let [b (keyword a) f (fn [& args] b)] `(deft

Macros and deftype – usage question

2012-04-28 Thread Shantanu Kumar
Hi, I am running into error when using macros with deftype. For example, when I use the macro `foo` it works fine: (defmacro foo [a] (let [b (keyword a)] `(do ~b))) (foo alex) => :b whereas, when I use the macro `bar`: (defmacro bar [a] (let [b (keyword a) f (fn [& args] b)]