Henrik, The reason for <> was that when at Akamai we had the idea to create a macro of this kind, we were aware of already established strong opinions for and against the idea of a threading macro with a specifiable position, by some in the Clojure community. Stephen Compall had been reading Scheme specifications and was aware of the cut operator and its semantics. Using the cut operator addresses one of the more valid concerns, namely that the semantics of % is not appropriate for an arrow, given the way that would imply some sort of lexical binding-- it's just confusing. We had to come up with a name for the macro itself, and I came up with -<> because of the way in which it echoes the cut operator <> itself. The -<> macro in swiss-arrows is a rewrite of the one we used at Akamai, but retains the name, the use of the cut operator, and the same basic idea modulo some later tweaks.
Rob On Sat, Nov 15, 2014 at 6:58 PM, Henrik Eneroth <henrik.ener...@gmail.com> wrote: > You can find this functionality in the Swiss Arrows library here: > https://github.com/rplevy/swiss-arrows > > My first thought was that using the % symbol seems cleaner than the <> of > Swiss Arrows. Thinking about it though, wouldn't overloading the % create > trouble when you do want to use the literal form of an anonymous function > within a %> clause? > > > On Saturday, November 15, 2014 2:55:51 PM UTC+1, Krzysiek Herod wrote: >> >> Guys, what do you think about new thread macro (I would call it >> thread-any and represent it as "%>"), that would require you to always >> specify the position of the argument you want to pass to the function? >> >> This code: >> >> (defn csv-line->sql-line [table, line] >> (-> line >> (str " ") >> (str/split separator) >> (#(map csv-field->sql-field %)) >> (#(str/join ", " %)) >> (str/replace strings-wrapper "\"") >> (#(str "INSERT INTO ", table, " VALUES(" % ");")))) >> >> would become: >> >> (defn csv-line->sql-line [table, line] >> (%> line >> (str % " ") >> (str/split % separator) >> (map csv-field->sql-field %) >> (str/join ", " %) >> (str/replace strings-wrapper % "\"") >> (str "INSERT INTO ", table, " VALUES(" % ");"))) >> >> Reasoning: >> - there are functions that are "thread-first fiendly", and other that are >> "thread-last friendly", by using thread-in you don't have to redefine >> functions only to change the order of the attributes >> - I find it easier to follow execution chain if the argument is passed >> explicitely >> >> PS. I'm a clojure newbie, still in the process of learning basics. For >> example I'm not sure how to implement such macro yet, so if you find >> something obviously wrong, or missing in my suggestion, please let me know. >> I'll be super happy to read about alternative solutions to achieve similar >> goal. >> > -- > 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. > -- 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.