On 24 November 2010 21:40, Mike Meyer
<mwm-keyword-googlegroups.620...@mired.org> wrote:
> Could someone explain where this urge to write (-> expr (func arg))
> instead of (func expr arg) comes from?

I like to use -> and ->> because they allow me to add more steps to
the "pipeline" as needed, without requiring ever more deeply nested
parentheses. Of course, the examples you cited were intentionally
trivial, but in a setting where you either have many consecutive
transformations on a piece of data, or you *expect* that these
transformations will grow numerous in the future, threading can help
keep the visual and cognitive complexity down. One could probably say
it makes nested s-exprs more scalable ;-)

Interestingly, in languages that prefer dot (.) method call notation
instead of prefix notation, the issue hasn't ever come up for me
because one generally doesn't have a choice. Take Pythons SQLAlchemy
as an example:

Customer.query.filter_by(validated=True).group_by('customer_gender').add_column(func.count()).values(Customer.customer_id)

Pretty neat, isn't it? The threading operators nicely introduce this
style of writing into the world of prefix notation.

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