Re: Weird GenSyms behaviour across different quoted blocks in a macro

2015-08-26 Thread Timothy Baldridge
Auto generated symbols (x# style) are only valid within a single syntax quote form. Instead declare the symbol ahead of time, something like this: (let [fsym (gensym "f_)] `(fn [~fsym] ~@(for [x (range 10] `(println ~fsym ~x Hope this helps. Timothy On Wed, Aug 26, 2015

Re: Weird GenSyms behaviour across different quoted blocks in a macro

2015-08-26 Thread Leon Grapenthin
What Ambrose said and: There is no need to use a hash for i in the for form. It is misleading because one thinks it will become a generated symbol as part of the generated form which is untrue. On Wednesday, August 26, 2015 at 11:08:12 PM UTC+2, Rafik NACCACHE wrote: > > Suppose I have the foll

Re: Weird GenSyms behaviour across different quoted blocks in a macro

2015-08-26 Thread Ben Wolfson
unify-gensyms from potemkin will fix this: https://github.com/ztellman/potemkin On Wed, Aug 26, 2015 at 2:07 PM, Rafik NACCACHE wrote: > Suppose I have the following macro, which generates a function that does > some repetitive generation, let's say: > > (defmacro a-macro > [m] > `(fn [f#]

Re: Weird GenSyms behaviour across different quoted blocks in a macro

2015-08-26 Thread Ambrose Bonnaire-Sergeant
You want an explicit gensym that scopes over both positions. (defmacro a-macro [m] (let [f (gensym "f)] `(fn [~f] ~(for [i# m] `(* (:val ~f) ~i# ) Thanks, Ambrose On Wed, Aug 26, 2015 at 5:07 PM, Rafik NACCACHE wrote: > Suppose I have the following macro, which ge

Weird GenSyms behaviour across different quoted blocks in a macro

2015-08-26 Thread Rafik NACCACHE
Suppose I have the following macro, which generates a function that does some repetitive generation, let's say: (defmacro a-macro [m] `(fn [f#] ~(for [i# m] `(* (:val f#) ~i# Note how I start with a quoted block in which I emit the fn header, and in which I use a gensym to