Re: preference and implications of using as-> vs let

2013-08-19 Thread Anand Prakash
Hi Jay Thanks for the reply. I did not know how as-> works, till I saw your example. I myself need to many a times chain things where in some cases the variable will go at the first location and in another cases it will go to the last location and it was a big pain to do something like what you

Re: preference and implications of using as-> vs let

2013-08-19 Thread Jay Fields
On Mon, Aug 19, 2013 at 6:41 PM, Anand Prakash wrote: > What is the major benefit of as-> > > => (-> 4 (#(* % %)) (+ 12) ) > > 28 > > => (-> 4 (as-> y (* y y)) (+ 12)) > > 28 Solving the contrived example doesn't really help answer the original question of preference and tradeoffs. As to the bene

Re: preference and implications of using as-> vs let

2013-08-19 Thread Anand Prakash
What is the major benefit of as-> => (-> 4 (#(* % %)) (+ 12) ) 28 => (-> 4 (as-> y (* y y)) (+ 12)) 28 On Monday, August 19, 2013 9:13:36 AM UTC-7, Ben Mabey wrote: > > On 8/19/13 8:58 AM, Jay Fields wrote: > > In the past, I've written code like the following > > > > (defn foo [x y] > >

Re: preference and implications of using as-> vs let

2013-08-19 Thread David Nolen
While I don't think I'd use it in your particular example, I like it when it can eliminate superfluous let bindings. (let [z (as-> (* x x) xsq ...)] ...) On Mon, Aug 19, 2013 at 10:58 AM, Jay Fields wrote: > In the past, I've written code like the following > > (defn foo [x y] >

Re: preference and implications of using as-> vs let

2013-08-19 Thread Steven Degutis
I personally think the only place as-> should be used is inside other threading macros. When it's used anywhere else, the name-goes-second ordering feels wrong and very awkward. On Mon, Aug 19, 2013 at 9:58 AM, Jay Fields wrote: > In the past, I've written code like the following > > (defn foo

Re: preference and implications of using as-> vs let

2013-08-19 Thread Mikera
I think a regular "let" is clearer in this kind of case. "as->" suggests to me that multiple rebindings will happen to the name: if that is not happening then it is confusing for readers IMHO. The only case I can think of where "as->" makes sense and the binding only happens once is if you are

Re: preference and implications of using as-> vs let

2013-08-19 Thread Ben Mabey
On 8/19/13 8:58 AM, Jay Fields wrote: In the past, I've written code like the following (defn foo [x y] (let [x-squared (* x x)] (if (pos? y) (+ x-squared y) (- x-squared y However, the introduction of as-> has led me to write the following, at times (defn foo [x y]