You are right, Alan! And in this case Closure compiler behave itself also unpredictably and quite the contrary: Where it must evaluate a symbol (like in this case), it doesn't. Where it mustn't evaluate a symbol (argument of macro), it does. So, need to have comprehensive and profound knowledge about its behavior, including subtleties, even in very simple use cases. Your explanation show this quite clearly.
On 27 сен, 02:42, Alan Malloy <a...@malloys.org> wrote: > I suspect your repl was stale, since this doesn't work at all. By an > amusing coincidence, though, it doesn't break, just returns the wrong > answer: > > user=> (defmacro infix [e] `(let [[x# f# y#] '~e] (f# x# y#))) > #'user/infix > user=> (infix (5 + 4)) > 4 > > That is, the *symbol* +, not the function +, is called as a function. > Symbols act like keywords in that they look themselves up in maps. The > "map" 5 does not contain the symbol '+, so the not-found value of 4 is > returned. > > On Sep 26, 10:22 am, ru <soro...@oogis.ru> wrote: > > > > > > > > > Thanks to all! > > > With your help I have found the solution that coincide with Bronsa's > > (my special respect to Bronsa): > > > user=> (defmacro infix [e] `(let [[x# f# y#] '~e] (f# x# y#))) > > #'user/infix > > user=> (infix (5 + 4)) > > 9 > > > But, this solution seems to me awkward and showing that Clojure > > compiler does not handling quite strictly language specification > > requirements. I.e., this single quote compiler should substitute > > itself to fulfill requirement of unevaluation arguments of macro. > > > Sincerely, > > Ru -- 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