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.

Reply via email to