2010/11/24 Mike Meyer <mwm-keyword-googlegroups.620...@mired.org> > On Wed, 24 Nov 2010 00:37:07 -0800 (PST) > LauJensen <lau.jen...@bestinclass.dk> wrote: > > You just touched on an idiom I see fairly often here that bugs me. I'm > not intentionally singling you - or CQL! - out for this, but you made > a comment that sets up my question perfectly. > > > (let [photo-counts (-> (table :photos) > > (aggregate [[:count/* :as :cnt]] [:id])))] > > (-> (table :users) > > (join photo-counts (= {:users.id :photos.id})) > > > > I think thats really as simple as you can express that join operation. > > Um, I can see two macros that, if expanded in place, would result in a > simpler expression (assuming that CQL doesn't redefine ->): > > (let [photo-counts (aggregate (table :photos) [[:count/* :as :cnt]] [:id])] > (join (table :users) photo-counts (= {:users.id :photos.id}))) > > I also fixed the parens - I think. I removed one after [:id], and it > seems like two were missing at the end as well. > > Ok, I understand why you would use -> if you're threading through > multiple forms. I don't know that I like it, but I can at least > understand it. But when it's only one form? In the best case - when > the form is a symbol, as in (-> 1 inc) - it just wastes three > characters to reverse the form and argument. More often - for example > (-> 1 (+ 2)) - it also adds another level of parenthesis, which I > thought most people considered a hindrance to comprehension. > > Could someone explain where this urge to write (-> expr (func arg)) > instead of (func expr arg) comes from? >
Maybe the lack of refactoring tools: expressions starting big, then some pieces are refactored out, but not totally ? I know my code looks like this sometimes, and I have to go back to it to remove these remaining (-> a b). -- 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