The primary point of let-> is that you can insert it into an existing -> pipeline.
(-> foo (stuff) (blah) (let-> foo-with-stuff (for [x foo-with-stuff] (inc x))) Your proposal breaks this. On Thursday, November 15, 2012 10:35:59 AM UTC-8, Alex Nixon wrote: > > Hi all, > > I find the proposed function let-> in Clojure 1.5 very useful, but a bit > ugly. The arguments are backwards when compared to vanilla let, and it > doesn't support destructuring where it easily could (which I believe would > be helpful when threading 'state-like' maps, as I find let-> very useful > for). > > I'd like to float an alternative implementation which improves on both > these issues. Thoughts? > > (defmacro new-let-> > "Establishes bindings as provided for let, evaluates the first form > in the lexical context of that binding, then re-establishes bindings > to that result, repeating for each successive form" > [bindings & forms] > (assert (vector? bindings) "binding must be a vector") > (assert (= 2 (count bindings)) "binding vector must contain exactly two > forms") > `(let [~@bindings > ~@(interleave (repeat (bindings 0)) (drop-last forms))] > ~(last forms))) > > (new-let-> [{:keys [foo bar] :as state} {:foo 1 :bar 2}] > (assoc state :foo (inc bar)) > (assoc state :bar (inc foo))) ; => {:foo 3, :bar 4} > > -- > *Alex Nixon* > > Software Engineer | SwiftKey > > *al...@swiftkey.net <javascript:>** | http://www.swiftkey.net/* > > ++++++ > WINNER - MOST INNOVATIVE MOBILE > APP<http://www.swiftkey.net/swiftkey-wins-most-innovative-app-at-mwc> > - GSMA GLOBAL MOBILE AWARDS 2012 > > Head office: 91-95 Southwark Bridge Road, London, SE1 0AX TouchType is a > limited company registered in England and Wales, number 06671487. > Registered office: 91-95 Southwark Bridge Road, London, SE1 0AX > > -- 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