Another advantage to the second form is that it doesn't collide with any versions of x you may have defined
;This will do weird stuff to x (let [x 2] (take-until1 (do-stuff-to-x))) ;This will behave like you expect (let [x 2] (take-until2 (do-stuff-to-x))) Meikel wrote a good set of guidelines for macros here: http://groups.google.com/group/clojure/browse_thread/thread/5ff31c9d7fc58b0b/ab76d7133414e243?lnk=gst&q=meikel+macro#ab76d7133414e243 Happy Hacking On Jun 22, 8:24 pm, arasoft <t...@arasoft.de> wrote: > I just wrote my first practice macro, first without and then with > syntax quoting: > > (defmacro take-until1 [function sq] > (list 'take-while (list 'fn (vector 'x) (list 'not (list function > 'x))) sq)) > > (defmacro take-until2 [function sq] > `(take-while (fn [x#] (not (~function x#))) ~sq)) > > Both seem to work, but macroexpand shows different formats: > > (macroexpand '(take-until1 #(> % 10) (iterate inc 1))) > -> (take-while (fn [x] (not ((fn* [p1__502] (> p1__502 10)) x))) > (iterate inc 1)) > > (macroexpand '(take-until2 #(> % 10) (iterate inc 1))) > (clojure.core/take-while (clojure.core/fn [x__405__auto__] > (clojure.core/not ((fn* [p1__506] (> p1__506 10)) x__405__auto__))) > (iterate inc 1)) > > While I prefer the syntax of macro 2, I like the expand format of > macro 1. > Is there any way to get the best of both worlds? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---