On 21 March 2016 at 23:47, Arun Sharma <arun.sha...@gmail.com> wrote:
> On Saturday, March 19, 2016 at 5:35:02 PM UTC-7, red...@gmail.com wrote: >> >> ->> is a mechanical transformation taking a form (->> x (a ... w)) >> turning it into (a ... w x), and this same mechanical transformation is >> in place when nested. You example expands in steps like: >> [..] >> >> you can see each step in the expansion results come from applying the >> exact same transformation (this transformation is exactly the ->> >> macro). this is the natural result of a recursive style of definition. >> While it is technically possible to change the behavior to what you are >> suggesting, but it would require special casing ->> and any derivative >> of ->>. >> > > Isn't it a function of how the recursive step is written? > No, it's a result of how macros are evaluated. Consider: user=> (macroexpand-1 '(->> a b c (x d e f))) (x d e f (c (b a))) If that makes sense, then just replace "x" with "->>": user=> (macroexpand-1 '(->> a b c (->> d e f))) (->> d e f (c (b a))) user=> (macroexpand-1 '(->> d e f (c (b a)))) (c (b a) (f (e d))) > The question I was asking is: does anyone rely on the current behavior? > For people adapting this syntax for a query language, it's appealing to > write: > > a->b()->c() > ->union(d->e()->f()) > > and get (union (c (b a) (f (e d))) > That's what: (-> a b c (union (-> d e f))) expands to. - James -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.