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

Reply via email to