Re: Macro newbie: Trying to create a map template

2009-10-24 Thread John Harrop
On Sat, Oct 24, 2009 at 2:43 PM, samppi wrote: > Thanks a lot! I didn't know about the existence of gensym. This will > help a lot. You're welcome. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. T

Re: Macro newbie: Trying to create a map template

2009-10-24 Thread samppi
Thanks a lot! I didn't know about the existence of gensym. This will help a lot. On Oct 23, 9:54 pm, John Harrop wrote: > On Sat, Oct 24, 2009 at 12:19 AM, samppi wrote: > > user=> (defmacro b [form] > >  (let [processed-form (a form rec#)] > >    `(fn [rec#] processed-form))) > > java.lang.Exc

Re: Macro newbie: Trying to create a map template

2009-10-23 Thread John Harrop
On Sat, Oct 24, 2009 at 12:19 AM, samppi wrote: > user=> (defmacro b [form] > (let [processed-form (a form rec#)] >`(fn [rec#] processed-form))) > java.lang.Exception: Unable to resolve symbol: rec# in this context > (NO_SOURCE_FILE:39) Try (defmacro b [form] (let [r (gensym) pr

Macro newbie: Trying to create a map template

2009-10-23 Thread samppi
I'm trying to create a macro called "procedure" so that: (procedure (and _x (pos? _y))) expands to (fn [rec#] (and (:x rec#) (pos? (:y rec# I'm stuck because I can't figure out a way to generate a symbol outside. I'm a newbie at macros, so I don't know if there's a better way around this: