2010/2/8 Meikel Brandmeyer <m...@kotka.de>:
> Hi,
>
> On Feb 8, 2:06 pm, Roman Roelofsen <roman.roelof...@googlemail.com>
> wrote:
>
>> Ah, that makes sense, thanks! Is using (gensym) the common solution
>> here? So far I thought that (gensym) is more a internal function that
>> I normally never need to call directly.
>
> In such a case using gensym is the normal solution. When you don't
> have the "escape" situation, using # is prefered since it removes the
> need for a surrounding let just containing gensym's.

There's also just another (rather uncommon ?) situation when one would
want to avoid using trailing #: if one wants to create bunchs of code
in a loop, where one wants to generate different syms everytime. This
does not work since sdfsdf# is generated once and for all at
read-time, and not everytime the code will be executed.

Example:

user=> (map (fn [k] `(println k foo#)) [:a :b :c])
((clojure.core/println user/k foo__6__auto__) (clojure.core/println
user/k foo__6__auto__) (clojure.core/println user/k foo__6__auto__))

user=> (map (fn [k] (let [foo (gensym "foo")] `(println k ~foo))) [:a :b :c])
((clojure.core/println user/k foo11) (clojure.core/println user/k
foo12) (clojure.core/println user/k foo13))

HTH,

-- 
Laurent

-- 
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

Reply via email to