On Sat, Oct 17, 2009 at 3:32 AM, Timothy Pratley
<timothyprat...@gmail.com>wrote:

>
> > But name is multiply evaluated. This might be preferable:
>
> Hi John,
>
> Could you explain this a bit more for me? I can understand if the
> condition is duplicated that is unnecessary calculation but don't
> appreciate the issue with the binding name... both versions of the
> macro seem to expand to identical code:
> user=> (macroexpand-1 '(while-let [a nil] (foo)))
> (clojure.core/loop [] (clojure.core/let [a nil] (clojure.core/when a
> (foo) (recur))))
> So my naive view was they would have identical behaviour/performance.
> I've heard this come up before but never understood or been able to
> find any reference about this 'issue'.


In this case, most often the name parameter will just be a symbol, but it's
generally a good idea to avoid reoccurrences of the same macro argument in
the macro expansion, except when it's needed. In this case the test and body
expression *should* be multiply evaluated for the semantics of a looping
construct to occur, though.

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